Display Property

Last updated: 2026-09-13

display Display Property

The display property defines how an element is presented in the page, whether it behaves as a block-level element, an inline element, or uses modern layout models such as Flex or Grid. It is one of the most fundamental and powerful properties in CSS layout, capable of changing almost any element's behavior in the document flow.

Category
Initial Valueinline
InheritedNo
Applies Toall
Animation Typediscrete
CSS VersionCSS1
StatusStandard

📝 Syntax

display: block | inline | inline-block | flex | grid | none | table | table-row | table-cell | contents | flow | flow-root | list-item;

⚙️ Values

ValueTypeDescription
block | inline | inline-block | flex | grid | none | table | table-row | table-cellKeywordPredefined display types.
contents | flow | flow-root | list-itemKeywordOther display types.

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
display v1 v12 v1 v1 v1
Supported in all major browsers
Tip: display:none removes an element from the document flow completely, taking no space and making it inaccessible to screen readers. If you only want to hide it visually while keeping its space, use visibility:hidden.
Important: On inline elements, width, height, and top/bottom margins have no effect. If you need horizontal layout with settable dimensions, use inline-block or flex.

❓ FAQ

QWhat's the difference between inline, inline-block, and block?
Ainline elements flow horizontally, cannot take width, height, or vertical margins, and are sized by content; vertical padding affects visuals but not layout. block elements take a full line and accept width, height, and all margins. inline-block combines both: it flows horizontally like inline while accepting dimensions and margins like block. Use inline-block when you need horizontal arrangement with controlled sizing.
QWhen should I use display:flex vs display:grid?
Aflex is for one-dimensional layouts with a single main axis, such as navbars, lists, centering, and two-column rows; children line up along the axis with automatic alignment and flexing. grid is for two-dimensional layouts where rows and columns are controlled together, such as full-page skeletons, card grids, and complex alignments. A simple rule: one row or column means flex; a grid-like pattern means grid.
QWhat's the difference between display:none and visibility:hidden?
Adisplay:none removes an element and its subtree from rendering entirely, taking no space, not being read by screen readers, and not being interactive. visibility:hidden only hides it visually; it keeps its space and is still read by screen readers. JavaScript event listeners on a display:none element still exist but never fire. For transitionable show and hide effects, visibility combined with opacity is a better fit.
QWhy doesn't width work on inline elements?
ABecause inline elements like span and a do not generate line boxes, so the browser ignores their width, height, and vertical margins. To let an inline element accept dimensions, change it to display:inline-block or block, or put it in a flex or grid container, where it becomes a flex or grid item and width applies normally. This also enables vertical padding to push the surrounding layout, which plain inline never does.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏