{"id":14045,"date":"2011-09-05T20:40:44","date_gmt":"2011-09-06T03:40:44","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14045"},"modified":"2021-10-15T11:50:23","modified_gmt":"2021-10-15T18:50:23","slug":"display","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/d\/display\/","title":{"rendered":"display"},"content":{"rendered":"\n
Every element on a web page is a rectangular box. The display property in CSS determines just how that rectangular box behaves.<\/p>\n\n\n\n
span.icon {\n display: inline-block; \/* Characteristics of block, but lays out inline *\/\n}<\/code><\/pre>\n\n\n\nThe default value for all elements is inline. Most “User-Agent Stylesheets” (the default styles the browser applies to all sites) reset many elements to “block.” Let’s go through each of these, and then cover some of the other less common values.<\/p>\n\n\n
Syntax<\/h3>\n\n\ndisplay: [ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy><\/code><\/pre>\n\n\n\n- Initial value:<\/strong>
inline<\/code><\/li>- Applies to:<\/strong> all elements<\/li>
- Inherited:<\/strong> no<\/li>
- Computed value:<\/strong> a pair of keywords representing the inner<\/a> and outer<\/a> display types plus optional list-item<\/a> flag, or a
<display-internal><\/code><\/a> or <display-box><\/code><\/a> keyword; see prose in a variety of specs for computation rules<\/li>- Animation:<\/strong> n\/a<\/li><\/ul>\n\n\n
Values<\/h3>\n\n\n
The display<\/code> property accepts keyword values. Those keywords can be grouped into different categories.<\/p>\n\n\n\n\/* <display-outer> (its natural flow). *\/\ndisplay: block;\ndisplay: inline;\n\n\/* <display-inner> (its contents) *\/\ndisplay: flex;\ndisplay: flow-root;\ndisplay: grid;\ndisplay: table;\ndisplay: ruby; \/* experimental *\/\n\n\/* <display-listitem> (generates a content box and an inline list-item box) *\/\ndisplay: list-tem;\ndisplay: inline list-tem;\n\n\/* <display-internal> (defines table and ruby layouts) *\/\ndisplay: table-row-group;\ndisplay: table-header-group;\ndisplay: table-footer-group;\ndisplay: table-row;\ndisplay: table-cell;\ndisplay: table-column-group;\ndisplay: table-column;\ndisplay: table-caption;\ndisplay: ruby-base; \/* experimental *\/\ndisplay: ruby-text; \/* experimental *\/\ndisplay: ruby-base-container; \/* experimental *\/\ndisplay: ruby-text-container; \/* experimental *\/\n\n\/* <display-box> (determines whether to display a box or not) *\/\ndisplay: contents;\ndisplay: none;\n\n\/* <display-legacy> (CSS2 single-keyword syntax) *\/\ndisplay: inline-block;\ndisplay: inline-flex;\ndisplay: inline-grid;\ndisplay: inline-table;\n\n\/* Two-value examples *\/\ndisplay: block flow;\ndisplay: inline flow;\ndisplay: inline flow-root;\ndisplay: block flex;\ndisplay: inline flex;\ndisplay: block grid;\ndisplay: inline grid;\ndisplay: block flow-root;\n\n\/* Global values *\/\ndisplay: inherit;\ndisplay: initial;\ndisplay: revert;\ndisplay: unset;<\/code><\/pre>\n\n\nExamples<\/h3>\n\ndisplay: inline<\/code><\/h4>\n\n\nThe default value for elements. Think of elements like\u00a0<span><\/code>,\u00a0<em><\/code>, or\u00a0<b><\/code>\u00a0and how wrapping text in those elements within a string of text doesn’t break the flow of the text.<\/p>\n\n\n\n