Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix 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 desk5 min

Why `height: 100%` Does Not Fit Its Parent (and the CSS Fixes That Work)

`height: 100%` cannot resolve against a content-sized parent. Here is how to diagnose the height chain and choose between explicit heights, viewport minimums, flexbox, and grid.

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.

height: 100% only fills a parent when the parent’s height is definite and available to the child. If the parent is sized by its content or has only min-height, the child’s percentage height usually resolves as auto. Use an explicit height chain for equal-height boxes, or use flexbox, grid, or a viewport-based min-height when the page should grow naturally.

Why the percentage height is ignored

CSS percentages are resolved against the height of an element’s containing block. The CSS Box Sizing specification states: “Percentages are resolved against the width/height, as appropriate, of the box’s containing block.” If that height depends on the child’s content, it is not definite enough to resolve an ordinary in-flow child’s percentage height, so height: 100% computes to auto.

As an Amazon Associate I earn from qualifying purchases.

This is why a parent with min-height: 400px does not automatically give a child a usable 100% height. min-height is a lower bound: it says the parent cannot be shorter than 400 pixels, but the parent’s used height may still be determined by its content. A minimum is not the same sizing input as an explicit height.

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

Check the containing-block height first

  1. Open developer tools and select the child with height: 100%.
  2. In the Computed styles panel, inspect its used height and the height of its direct parent.
  3. Walk up every ancestor that participates in the percentage chain. Look for an explicit height, an auto/content-sized height, or only a min-height.
  4. Check whether the child is in normal block flow, a flex container, a grid container, or absolutely positioned; each formatting context applies additional sizing rules.
  5. Inspect padding, borders, overflow, and automatic minimum sizes after the basic height issue is identified.

Without the markup and computed styles, no single declaration can explain every case. The same symptom can come from an indefinite parent height, flex or grid minimum sizing, box-model overflow, or an intentional content-growing design.

#1 Best Overall

Use a definite height when the child must match the parent

Give the relevant containing block a definite height, and establish one on each ancestor between it and the child when necessary.

html, body {
  height: 100%;
}

.page {
  height: 600px;
}

.panel {
  height: 100%;
}

The chain matters: if .page is height: 100% but its parent has no definite height, the chain still cannot resolve. Choose a definite value that reflects the actual available space, such as a known component height or a height supplied by the surrounding layout.

Account for padding and borders

By default, height applies to the content box. A child set to 100% can therefore become taller than the visual space once its own padding and borders are added.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.panel {
  box-sizing: border-box;
  height: 100%;
  padding: 1rem;
  border: 1px solid currentColor;
}

box-sizing: border-box makes the declared height include the child’s padding and border. It prevents that particular form of overflow, but it cannot make an indefinite parent height definite.

When the page should be at least viewport-tall

For a page shell that should reach the viewport and expand as content grows, use a viewport-based minimum on the shell and let normal flow determine the content height. Do not make a child derive its height from that minimum.

.page {
  min-height: 100vh;
}

100vh represents the large viewport. On mobile, browser interface controls can make the visible area different from that value. CSS also provides viewport variants:

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
Unit Behavior Use when
svh Small viewport height You need a stable value that fits the smallest browser viewport.
lvh Large viewport height You want the maximum viewport size; this is the basis of vh.
dvh Dynamic viewport height The shell should track the currently visible viewport as browser controls appear or disappear.
.page {
  min-height: 100dvh;
}

Choose the unit according to the desired mobile behavior and verify it on the browsers and devices you support.

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

Prefer flexbox for columns and a footer pushed down

If the goal is a full-height page with a header, flexible content area, and footer, flexbox usually expresses the layout better than percentage heights.

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

The page can grow when content exceeds the viewport, while flex: 1 consumes remaining space when there is extra room. The main element does not need height: 100%.

Allow a constrained flex child to shrink

In a constrained flex column, the automatic minimum size can prevent a child from shrinking and can produce overflow instead of the scrolling behavior you expect. Set min-height: 0 on the appropriate child, then define where scrolling belongs.

.layout {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.content {
  min-height: 0;
  overflow: auto;
}

This is a flex sizing and overflow fix, not a general replacement for a missing percentage-height chain. Confirm that scrolling the content region is the intended result.

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

Use grid when tracks should divide available space

Grid can assign available height directly to rows, avoiding manual percentage heights.

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
.layout {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.content {
  overflow: auto;
}

minmax(0, 1fr) lets the middle track shrink to the available space rather than honoring an automatic minimum that forces the grid to overflow. As with flexbox, set overflow deliberately and test long content.

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

Common fixes that fail

  • Adding height: 100% to both parent and child without a definite ancestor: the percentage chain remains unresolved.
  • Replacing min-height with a fixed height without considering content: content can overflow or be clipped when it exceeds the chosen value.
  • Adding more percentage heights inside an auto-sized component: percentages still have no definite reference and may compute to auto.
  • Using box-sizing: border-box as the only fix: it handles padding and border arithmetic, not an indefinite containing block.
  • Assuming a viewport unit solves every layout: mobile browser controls and the choice between stable, large, and dynamic viewport behavior still matter.

Choose the sizing strategy by the intended behavior

Requirement Suitable approach Important check
Child must equal a known parent height Provide a definite height through the containing-block chain; use height: 100% only where that chain is definite. Include padding and borders with box-sizing: border-box when appropriate.
Page must fill the viewport but grow with content Use min-height with vh, svh, lvh, or dvh. Select the viewport variant for the target mobile behavior.
Header, content, and footer share available space Use flexbox or grid. Check automatic minimum sizes and overflow.
Content should scroll inside a constrained region Give the layout a real available height, then apply overflow: auto to the scrolling child. In flex or grid, use min-height: 0 or minmax(0, 1fr) where needed.
Content should expand the page naturally Leave the content height as auto; avoid forcing 100% heights. Use normal flow and a shell minimum rather than a child percentage.

A practical debugging example

Suppose a section has min-height: 500px and its child has height: 100%. If the section’s content is only 200px tall, the section may still be at least 500px visually, but its used height was not supplied as a definite percentage reference. The child therefore remains content-sized. If the section later grows to 800px because of content, the child does not automatically become an 800px percentage box.

If the section must be an exact 500px component, use height: 500px (or a definite height from its layout context) and handle excess content with an intentional overflow policy. If it is a page shell, keep min-height, remove the child’s percentage height, and use flex or grid to distribute spare viewport space.

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

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

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.

Leave a Reply

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

Free tools Windows power users keep installed

One-click scans. No signup required.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.