Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

display — box generation and layout model

The display property controls an element’s box generation, participation in layout, and arrangement of its contents.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

display: block | inline | flow-root | flex | grid | inline-block | inline-flex | inline-grid | none | contents;
display: block flex;
display: inline flex;

display controls CSS boxes, not DOM structure. Its initial value is inline; it is not inherited.

The outer type controls layout participation; the inner type controls content layout. inline flex combines inline participation with flex layout, matching inline-flex. flex means block flex; inline-block matches inline flow-root. The syntax shown is selective, not the complete grammar.

none removes the entire subtree’s boxes. contents normally removes only the element’s box; descendants still participate in layout. Replaced elements have exceptions. Check accessibility in target browsers before using contents.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>display</title>
<style>
  .items { display: inline flex; }
  .removed { display: none; }
</style>
<body>
  <div class="items"><span>A</span><span class="removed">X</span><span>B</span></div>
</body>
</html>

Result

AB

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources