02. Display

To control how elements flow within our content, we use the display property.

The possible values include: inline, block, andinline-block.

Inline

A value of inline makes the element displayed within the flow of a line.

Some examples of inline-block elements that you may have seen are <span>, <em>, and <markup>

Remember that these elements do not start their own block, but rather situate themselves with the flow of the surrounding content.

Block

When the display is set to block, the element is positioned with line breaks under and over it. Some of the default block elements in HTML include: <h1> and <p> tags.

Inline-block

In case you wanted a hybrid of both, we can specify, inline-block level elements. Here, the element will flow like an inline-element, but are able to have a specified height.

None

Using a value of none takes that element completely out of the page. This is useful for switching the visibility of an element on and off.

display: none vs. visibility: hidden

There is another CSS property similar to display: none called visibility: hidden that can also hide elements.

The difference is that display: none takes the element box completely out of play, while visibility: hidden keeps the box and flows it in place without the contents being visible.

If you don't want a blank space to appear, use display: none.

Aching back from coding all day?

Self-Massage Tool

Aching back from coding all day? Try Back Problems

Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.

$ Check price
29.9529.95Amazon 4.5 logo(3,443+ reviews)

More Back Problems resources

Build modern and responsive webpages

HTML & CSS

Build modern and responsive webpages Try Front-end

This book teaches HTML as if it's for anyone - hobbyists, students, and professionals - and it's full-color throughout. It utilizes information graphics and lifestyle photography to explain the topics in a simple way that is engaging. You can progress through the chapters from beginning to end or just dip into topics of particular interest at your leisure.

$ Check price
29.9929.99Amazon 4.5 logo(926+ reviews)

More Front-end resources

Ad