Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk2 min

Why a Div Does Not Grow with `height: 100%`

A percentage height is not a minimum. Use min-height when a div must fill its parent and still grow with longer content.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a block should fill at least the viewport-height area and expand when its text gets longer, replace height: 100% with min-height: 100%. A percentage height sets a height relative to the containing block; it does not mean “fill the screen, then grow with all content.”

Why the div stops growing

In the SitePoint forum example, the page sets html and body to height: 100%, then gives a child div height: 100%. The block looks right with a few lines, but longer text extends beyond its set height rather than making that height increase.

That is the distinction between a specified height and a minimum height. height: 100% asks for a height based on the containing block. The W3C CSS Box Sizing specification states that percentages are resolved against the corresponding dimension of the containing block. A height declaration is not a promise to keep stretching as content grows.

Percentage heights also depend on the containing block’s height being resolvable. Under the CSS 2.1 percentage-height rule, when a non-absolutely positioned element’s containing-block height is not explicitly specified and depends on content, its percentage height computes to auto. So check the relevant parent heights rather than assuming height: 100% automatically means viewport height.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Use min-height when content should make the page taller

For the forum example’s apparent goal—a green block at least as tall as the viewport-sized ancestor, but able to grow with longer text—use:

html, body {
  height: 100%;
}

div {
  min-height: 100%;
  max-width: 18.75em;
  background-color: #008000;
}

min-height: 100% sets a floor: the block can be at least as tall as its containing block, and its content can make it taller. The forum replies recommend it in place of height: 100% for this content-growing case, and caution against fixed heights on elements holding fluid text.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose sizing by the behavior you want

  • Natural content growth: use min-height when the block should fill a minimum area and grow as needed.
  • Fixed panel: use a fixed height when the design calls for a bounded panel, and choose an explicit overflow behavior such as scrolling or clipping.
  • Percentage height in a nested layout: inspect the containing block and its ancestors. A percentage needs a usable reference height; content-sized ancestors can change how it resolves.

The SitePoint thread concerns a simple block in ordinary page flow and dates to August 2018; it does not establish behavior across every layout context or browser. If the element is inside a grid, flex, positioned, or otherwise nested layout, verify the containing block and the intended overflow behavior for that layout.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 3
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 5
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.94
Best Value
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.