The display property is the most important CSS property for controlling layout. It specifies how an element is displayed on the screen and how it interacts with other elements.
display: blockBlock-level elements always start on a new line and take up the full width available. Common examples include <div>, <h1>, and <p>.
div { display: block; }
display: inlineInline elements only take up as much width as necessary and do not force a new line. Important restriction: You cannot set the width or height of an inline element.
span { display: inline; }
display: inline-blockElements behave like inline (they sit next to each other), but you are allowed to set the width and height.
div { display: inline-block; width: 100px; }
display: noneThe element is completely removed from the page. It takes up no space whatsoever. This is commonly used in navigation menus to hide subsections until they are needed.
.hidden-element {
display: none;
}
It's important to understand the difference between display: none and visibility: hidden.
display: none is highly effective for toggling navigation menus and modal popups using JavaScript.