CSS Display
The display property is the most important CSS property for controlling layout.
CSS Display Property
The display property specifies how an element is displayed.
Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline.
Example 1: Block-level Elements
A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
Examples of block-level elements: <div>, <h1>-<h6>, <p>, <form>, <header>, <footer>, <section>.
Example 2: Inline Elements
An inline element does not start on a new line and only takes up as much width as necessary.
Examples of inline elements: <span>, <a>, <img>.
Example 3: Display: none
display: none; is commonly used with JavaScript to hide and show elements without deleting and recreating them. The element will be hidden, and the page will be displayed as if the element is not there.
This is a visible paragraph.
The paragraph above is hidden.
Example 4: Override The Default Display Value
As mentioned, every element has a default display value. However, you can override this. Changing an inline element to a block element, or vice versa, can be useful for making the page look a specific way, and still follow the web standards.
A list of links displayed as a horizontal menu: