CSS · CSS Tutorial · Lesson 20
CSS Display
block, inline, inline-block and none.
The display property specifies how an element is shown. Every element has a default display value.
Example
<style>
li { display: inline; margin-right: 12px; }
span.block { display: block; background: lightblue; }
.hidden { display: none; }
.invisible { visibility: hidden; }
</style>
<ul><li>Home</li><li>About</li><li>Contact</li></ul>
<span class="block">A span shown as block</span>
<p class="hidden">You cannot see me (no space kept)</p>
<p class="invisible">Hidden, but my space is kept</p>
<p>End.</p>
| Value | Behaviour |
|---|---|
| block | New line, full width |
| inline | Same line, width of content, ignores width/height |
| inline-block | Same line, but respects width/height |
| none | Removed from the page |
| flex / grid | Modern layout containers |
Keep reading “CSS Display”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.