Nic727 0 Posted January 13, 2019 Report 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 Quote Link to post Share on other sites
dsonesuk 913 Posted January 13, 2019 Report 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. Quote Link to post Share on other sites
Nic727 0 Posted January 15, 2019 Author Report Share Posted January 15, 2019 ok thank you Quote Link to post Share on other sites
shaili_shah 1 Posted November 15, 2019 Report 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. Quote Link to post Share on other sites
dsonesuk 913 Posted November 15, 2019 Report 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.