Why Normalize.css Sets `display: block` on the `<main>` Element

Normalize.css sets display: block on the <main> element to force block-level rendering in legacy browsers like Internet Explorer 11, which otherwise treat unknown HTML5 semantic elements as inline and cause layout bugs.

The necolas/normalize.css repository provides a modern, cross-browser CSS reset that preserves useful browser defaults while smoothing out inconsistencies. When working with HTML5 semantic elements, understanding why Normalize.css explicitly declares display: block on <main> prevents unexpected rendering issues in older browsers. This article examines the technical reasoning behind this specific normalization rule found in the core stylesheet.

The HTML5 <main> Element and Legacy Browser Gaps

The <main> element represents the dominant content of the <body> of a document and is defined in the HTML5 specification as a sectioning element with default block-level behavior. While modern browsers implement this correctly, legacy browsers—specifically Internet Explorer 11 and earlier—do not recognize the element at all.

How IE Handles Unknown Elements

When IE 11 encounters an element it does not recognize, it treats that element as an inline element by default. This causes the browser to apply inline layout rules to <main>, meaning:

  • The element collapses to the width of its content rather than expanding to fill its container
  • Vertical margins and padding behave unpredictably
  • Block-level children may not layout correctly within the inline parent

This inline treatment contradicts the HTML5 specification and breaks page layouts that rely on <main> as a full-width container for primary content.

The Normalize.css Implementation

To resolve this cross-browser inconsistency, Normalize.css includes a targeted, minimal rule in normalize.css at lines 27–33:

/* Render the `main` element consistently in IE. */
main {
  display: block;
}

This declaration serves three specific purposes:

  1. Ensures block-level behavior – Guarantees that <main> expands to the full width of its container, respects vertical margins, and properly contains block-level children without requiring additional CSS in user stylesheets.

  2. Aligns with the HTML5 specification – Forces older browsers to match modern browser defaults, making <main> behave consistently with other semantic sectioning elements like <section> and <article>.

  3. Prevents layout collapse – Eliminates bugs where the main content would wrap oddly or collapse inappropriately, particularly when developers use the element as a wrapper for grid or flex layouts.

The rule is intentionally minimal, setting only the display property to avoid interfering with other styling choices.

Practical Layout Consistency

Without this normalization, developers targeting legacy browser support would need to manually declare display: block on every project. Normalize.css abstracts this fix into the reset layer, providing a reliable baseline.

Preventing Inline Layout Bugs

When treated as inline, the <main> element inherits text-flow characteristics that break typical page layouts. The Normalize.css rule ensures that margins, padding, and width calculations behave as expected across all browsers, preventing scenarios where the primary content container collapses or fails to establish a proper formatting context.

Integrating with Modern Layouts

The normalization does not prevent developers from overriding the value later. Since Normalize.css uses a low specificity element selector, you can freely change the display type to flex or grid in your custom styles without fighting the reset.

Code Examples

Basic Usage with CDN

Include Normalize.css in your HTML to ensure consistent <main> rendering across browsers:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Example Page</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8/normalize.css">
  <style>
    main {
      padding: 2rem;
      background: #f5f5f5;
    }
  </style>
</head>
<body>
  <header>Header</header>
  <main>
    <h1>Welcome</h1>
    <p>This content is inside the `<main>` element.</p>
  </main>
  <footer>Footer</footer>
</body>
</html>

Overriding with Flexbox

Change the display type to suit your layout needs without specificity conflicts:

/* Change the main element to a flex container */
main {
  display: flex;          /* overrides Normalize's block rule */
  flex-direction: column;
  gap: 1rem;
}

Summary

  • Normalize.css forces display: block on <main> to fix Internet Explorer 11's default inline treatment of unknown HTML5 elements.
  • The rule appears at lines 27–33 in normalize.css with the comment "Render the main element consistently in IE."
  • This ensures the element expands to full width, respects vertical margins, and contains block-level children properly.
  • The normalization is minimal and non-interfering, allowing easy overrides with flex, grid, or other display values in custom stylesheets.

Frequently Asked Questions

Why does Internet Explorer treat <main> as an inline element?

Internet Explorer 11 and earlier versions do not recognize the <main> element as a valid HTML5 tag. When a browser encounters an unrecognized element, it treats it as a generic inline element by default, applying text-flow layout rules rather than block container behavior. Normalize.css corrects this by explicitly declaring display: block according to the actual specification.

Can I override the display: block rule in Normalize.css?

Yes. The selector in normalize.css uses a simple element selector (main) with low specificity, making it easy to override. You can declare display: flex, display: grid, or any other value in your custom CSS, and it will take precedence without requiring !important or complex specificity calculations.

Do modern browsers like Chrome and Firefox need this rule?

Modern browsers correctly implement the HTML5 specification and render <main> as block-level by default. However, Normalize.css includes this rule as part of its cross-browser baseline to ensure consistency when supporting older browsers like IE11. Removing it would not affect modern browsers but could break layouts in legacy environments.

Does Normalize.css set other properties on the <main> element?

No. The rule in normalize.css specifically targets only the display property for the <main> element. Normalize.css follows a philosophy of minimal, surgical corrections—setting only the properties necessary to fix browser inconsistencies—allowing developers full control over padding, margins, colors, and other stylistic choices.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →