Skip to content
Fix Code Error

Make body have 100% of the browser height

March 13, 2021 by Code Error
Posted By: Anonymous

I want to make body have 100% of the browser height. Can I do that using CSS?

I tried setting height: 100%, but it doesn’t work.

I want to set a background color for a page to fill the entire browser window, but if the page has little content I get a ugly white bar at the bottom.

Solution

Try setting the height of the html element to 100% as well.

html, 
body {
    height: 100%;
}

Body looks to its parent (HTML) for how to scale the dynamic property, so the HTML element needs to have its height set as well.

However the content of body will probably need to change dynamically.
Setting min-height to 100% will accomplish this goal.

html {
  height: 100%;
}
body {
  min-height: 100%;
}
Answered By: Anonymous

Related Articles

  • Web colors in an Android color xml resource file
  • Navbar not filling width of page when reduced to mobile view
  • Bootstrap - center child when parent isn't centered…
  • Best way to extract messy HTML tables using BeautifulSoup
  • How to show title in hover - css / jquery
  • Having trouble with my nav bar/header, It used to…
  • Active tab issue on page load HTML
  • How to prevent scrolling the whole page?
  • Is it possible to apply CSS to half of a character?
  • How do I keep only the first map and when the game…
  • Animating Elements in One by One
  • Unresponsive hamburger icon in HTML
  • How to blur the background after click on the button…
  • How do i update a javascript variable as its value changes?
  • How to stretch the div to all the height of the page?
  • Fix top buttons on scroll of list below
  • GLYPHICONS - bootstrap icon font hex value
  • My DIV elements go diagonal instead of horizontal
  • Safe truncate string contains color tag
  • Bootstrap 4.6 + CSS, how to bottom align a row
  • Difference between variable declaration syntaxes in…
  • Javascript text animation not triggering
  • After a little scroll, the sticky navbar just is not…
  • Trouble with boxes appearing/hiding based on selection
  • Adobe XD to responsive html
  • Centering in CSS Grid
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • Change background color on mouseover and remove it…
  • What are the nuances of scope prototypal /…
  • Content showing over the top of tooltip
  • Is it possible to move my text side by side with my icon
  • Azure Sql : Unable to Replace HTML String
  • Managing longs and short orders like LucF PineCoders…
  • Jquery fadeToggle Trouble
  • SQL query return data from multiple tables
  • How can we load color from a sequential scale into a…
  • Reset/remove CSS styles for element only
  • Increasing size of semi circle using css
  • HTML5 Canvas Resize (Downscale) Image High Quality?
  • Chrome / Safari not filling 100% height of flex parent
  • Polymer CSS inline elements alignment
  • How to use html template with vue.js
  • custom text position on ipywidgets button
  • app-theme.html not working in custom element
  • How to change a card header color with a Select…
  • Why does I can't add background image even I use static
  • The theme changer for my code does not seem to work
  • How do I do a drag and drop using jQuery to move…
  • geoXML3 "not a LatLngBounds" error in custom…
  • Change navbar color in Twitter Bootstrap
  • What is causing this broken animation/transition in…
  • AppCompat v7 r21 returning error in values.xml?
  • Dynamically update values of a chartjs chart
  • CSS Variable trough Polymer (dynamically loaded) elements
  • "Non-resolvable parent POM: Could not transfer…
  • Remove Text from the edit text when edit text is focused
  • In CSS Flexbox, why are there no "justify-items" and…
  • Android : Fragment doesn't fit into Fragment Container
  • Bootstrap 3 - jumbotron background image effect
  • iron-iconset-svg and var(--primary-text-color);
  • Fragment Not Showing in the Activity
  • center 3 items on 2 lines
  • don't know what went wrong nav bar with Tailwind CSS…
  • React Multi-level push menu SCSS Back button not working
  • How to change the color of vaadin-select-text-field…
  • I cant get my type writer heading to the center of my code
  • Why my "title" bloc doesn't go to bottom?
  • WPF C# button style
  • Do not close the mode in the mouse up event
  • Smart way to truncate long strings
  • Keeping the User logged in
  • CSS grid wrapping
  • What's the difference between -fx-text-fill and…
  • how to use canvas in JavaScript flappy bird code
  • Selectively suppressing legend in altair plot
  • Javascript change color of text and background to…
  • CSS animation as a Google Map Marker (Polymer 1.0)?
  • How to show 6 different images when in load the…
  • CSS curtains, it rimains opened when the site is runned up
  • How do you get string interpolation working on a…
  • CSS Input with width: 100% goes outside parent's bound
  • Gradient text color
  • Why are CSS keyframe animations broken in Vue…
  • functions deleting the paint canvas
  • Why is there a tiny indent on the left side of the footer?
  • Why doesnt my table sort my div variable in numerical order?
  • Vue.js - prop sync not instant
  • error at for loop: Expected an identifier in Flutter
  • Vertical Align Center in Bootstrap 4
  • How can I use/create dynamic template to compile…
  • Daisy is overlapping the other contents of the div
  • How to update polymer element bindings after it was…
  • Decreasing height of bootstrap 3.0 navbar
  • Vertically align an image inside a div with…
  • CSS Animation Depending on Child Element
  • Onclick event not happening when slick slider is…
  • Zoom in on a point (using scale and translate)
  • Make Iframe to fit 100% of container's remaining height
  • How to specify height of nested web component custom…
  • pandas create new column based on values from other…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Get string character by index – Java

Next Post:

How can I start PostgreSQL server on Mac OS X?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error