Nic727 Posted January 13, 2019 Share Posted January 13, 2019 Hi, What is the best use of height for the HTML and body tag? I currently use auto to don't have problem, but for my design, I need a background image to be height 100%. Should I use background height 100vh or 100% and have body/html height at 100%? Thank you Link to comment Share on other sites More sharing options...
dsonesuk Posted January 13, 2019 Share Posted January 13, 2019 If you set height of body, html to 100vh they will not extend beyond current viewport height of devices orientation, whatever the content and will show content beyond this background image when scrolled If you set height of body, html to 100% they will extend to and beyond current viewport height only when content exceeds beyond that height of devices orientation and scroll along with extended background image. Now depending what you want! You could use background-attachment: fixed; with height: 100vh to prevent background image scrolling up with content to show content extending beyond this html, body height background image. Link to comment Share on other sites More sharing options...
Nic727 Posted January 15, 2019 Author Share Posted January 15, 2019 ok thank you Link to comment Share on other sites More sharing options...
shaili_shah Posted November 15, 2019 Share Posted November 15, 2019 If you're trying to apply background images to html and body that fill up the entire browser window, neither. Use this instead: html{ height : 100%;} body{min-height : 100%;} the reason why you have to specify height and min-height to html and body respectively is because neither element has any intrinsic height. Both are height: auto by default. It is the viewport that has 100% height, so height: 100% is taken from the viewport, then applied to body as a minimum to allow for scrolling of content. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 15, 2019 Share Posted November 15, 2019 I'm sure I've seen that same answer before, but I can't in the life of me remember where? Wait! I found it! https://stackoverflow.com/questions/17555682/height-100-or-min-height-100-for-html-and-body-elements Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now