codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS display

CSS display

Block, inline, none, flex, grid.

display sets how an element takes part in layout. none removes it; visibility:hidden hides it but keeps its space.

Commands in this lesson

display

Definition: Sets how an element is laid out: block, inline, flex, grid or none.

Syntax:

display: value;

Example:

display: flex;
justify-content: center;

Example code

<style>
span.b{display:block;background:#cde}
p.h{display:none}
</style>
<span class='b'>Span as block</span><p class='h'>Hidden</p><p>Visible</p>

Run this code in the online editor

← CSS tablesCSS max-width →