CSS display Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The display property sets whether an element is treated as a block or inline box, and which layout its children use — normal flow, flex, grid, or none.

Formally it sets an outer type (role in flow) and an inner type (how children lay out). Everyday keywords such as flex mean block flex. The property is not inherited.

Baseline · Widely available.

Not deprecated. Core values work across modern browsers. Some newer keywords have limited support.

Experimental grid-lanes

grid-lanes / inline-grid-lanes are newer layout modes. Skip them until you need them and check browser support.

CSS Syntax

syntax.css
display: block | inline | inline-block | flex | grid | none | …;

Short form is enough for most work. Multi-keyword form also exists: display: inline flex; equals inline-flex.

Property Values

ValueDescriptionTry it
blockBlock box. Starts on a new line; takes available widthTry it
inlineFlows with text. Width and height do not apply as on a blockTry it
inline-blockSits in a line like text, but accepts width, height, and paddingTry it
flexBlock-level flex container for one-dimensional layoutsTry it
gridBlock-level grid container for rows and columnsTry it
noneNo box. Removed from layout and the accessibility treeTry it
contentsElement's own box is skipped; children still renderTry it
flow-rootBlock box that always creates a new block formatting contextTry it

Also common: inline-flex, inline-grid, list-item, and table-related values. Start with the table above.

How to Use display

Pick the value that matches how the box should sit in the page and how its children should arrange.

  1. Decide the element's role: block section, inline bit of text, or a layout container.
  2. Choose a keyword: block, inline, inline-block, flex, grid, or none.
  3. For flex or grid, set the container's display, then size and place the children.
  4. To hide content, prefer patterns that keep accessibility when the content must still be announced.
PieceRequired?Role
KeywordYesSets outer and/or inner display type
ChildrenFor flex/gridLayout modes arrange direct children
InheritedNoSet on each element that needs a change
HTML defaultOften enoughMany tags already have a useful UA display

Live Preview

Change display on the dashed box. Surrounding text shows how the box sits in flow.

Flex and grid also rearrange the three children inside the box.

In flow
Text A
123
Text B

display: block

CSS Examples

Each snippet focuses on display. Use Try It Yourself for a live editor.

Example 1 — Inline-Block Boxes

Place boxes in a line while keeping width and padding.

CSS
<style>
  .chip {
    display: inline-block;
    width: 4rem;
    padding: 0.5rem;
  }
</style>

<span class="chip">A</span>
<span class="chip">B</span>
Try It Yourself

How It Works

  1. Stay in flow. inline-block keeps the boxes on one line with surrounding text capacity.
  2. Accept sizing. Unlike plain inline, width and padding apply as expected.
  3. Compare with block. A block chip would stack on its own line.
  4. Open the editor and switch the value between inline and inline-block.

Example 2 — Flex Container

Turn a parent into a one-dimensional layout container.

CSS
<style>
  .row {
    display: flex;
  }
</style>

<div class="row">
  <span>1</span><span>2</span><span>3</span>
</div>
Try It Yourself

How It Works

  1. Set the container. display: flex makes the parent a flex formatting context.
  2. Children become flex items. They sit on one main axis by default.
  3. Outer type is block. The flex container itself still starts on a new line.
  4. Next steps. Learn alignment and growth on the flex page.

Example 3 — Hide with None

Remove a box from layout completely.

CSS
<style>
  .gone {
    display: none;
  }
</style>

<p>Visible</p>
<p class="gone">Hidden</p>
<p>Also visible</p>
Try It Yourself

How It Works

  1. No box is generated. The hidden paragraph takes no space.
  2. Descendants are hidden too. Nested content is also removed from layout.
  3. Accessibility. none removes the element from the accessibility tree.
  4. Keep space instead? Use visibility: hidden when the gap must remain.

Edge Cases & Pitfalls

If layout or accessibility looks wrong, check these first.

a11y

display: none removes from the accessibility tree

Screen readers skip the element and its descendants. Do not use none for content that must still be announced.

contents

display: contents has accessibility caveats

Some browsers incorrectly drop the element itself from the accessibility tree. Prefer simpler markup when semantics matter.

tables

Changing table display can break announcements

Setting a table to block, flex, or grid can change how assistive tech exposes it. Keep real tables as tables when possible.

inline

Width and height on pure inline

display: inline ignores width/height the way a block would. Switch to inline-block, block, or a replaced element.

flex/grid

Set display on the container

flex and grid apply to the parent. Children become items automatically — you do not set display: flex on every child.

Browser Support

display is a browser CSS property for layout. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

display

Core keywords (block, inline, flex, grid, none) work in all modern browsers. Newer values such as grid-lanes are experimental.

98% Core value support
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Opera All modern versions
Full support
Samsung Internet Supported
Full support
Internet Explorer Legacy keywords; no modern grid
Partial
display Widely supported

Bottom line: Safe for everyday layout keywords. Check support before relying on experimental values. It is not a runtime API.

Key Takeaways

  • Role: set the box type and the children's layout mode.
  • Common picks: block, inline, inline-block, flex, grid, none.
  • Not inherited. HTML tags already ship with useful defaults.
  • Hide carefully: none removes layout and accessibility exposure.

One line: use display to choose the box and the layout engine — flex and grid on the parent, not on every child.

Frequently Asked Questions

It sets how an element participates in layout (block or inline) and how its children are laid out (flow, flex, grid, and similar).
The CSS initial value is inline, but browsers set defaults per HTML tag. For example, div is block and span is inline in the user-agent stylesheet.
Block boxes start on a new line and stretch to the available width. Inline boxes flow with text and only take the width of their content.
Use it when items should sit in a line like text but still accept width, height, and vertical padding or margin like a block.
No. It stays in the document but generates no box, takes no space, and is removed from the accessibility tree. Prefer visibility or visually-hidden patterns when assistive tech still needs the content.
Core values are Baseline Widely available. Newer keywords such as grid-lanes are experimental. It is a browser CSS property, not a Node.js feature.

Next: empty-cells

Show or hide empty table cells borders.

empty-cells tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful