inline
span
is the standard inline element. An inline element can wrap some text inside a paragraph
<span>
like this
</span>
without disrupting the flow of that paragraph. The a
element is the most common inline element, since you use them for links.
none
Another common display value is none
. Some specialized elements such as script
use this as their default. It is commonly used with JavaScript to hide and show elements without really deleting and recreating them.
This is different from visibility
. Setting display
to none
will render the page as though the element does not exist. visibility: hidden;
will hide the element, but the element will still take up the space it would if it was fully visible.
other display values
There are plenty of more exotic display values, such as list-item
and table
. Here is an exhaustive list. We'll discuss inline-block
and flex
later on.
extra credit
As I mentioned, every element has a default display type. However, you can always override this! Though it wouldn't make sense to make an inline div, you can use this to customize the display of elements that have particular semantics. A common example is making inline li
elements for horizontal menus.