CSS Display Properties

CSS Layout – The display Property

The display the 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.

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>

Inline Elements

An inline element only takes up width as much as necessary. 

Examples of inline elements:

  • <span>
  • <a>
  • <img>

Display: none;

display: none; is usually used with JavaScript to show and hide elements without deleting and recreating them.

Display Inline Property

Override The Default Display Value

Every element has a default display value and 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.

Display Block Property

Setting the display property of an element only changes how the element is displayed, NOT what type of element it is. So, an inline element with display: block; is not allowed to have other block elements inside it.

The following example of displaying <span> and <a> elements as block elements:

Display Hidden Property

In HTML you can hide any element by just setting the display property to none and the page will be displayed as if the element is not there:

Visibility Hidden Property

In HTML you can hide any element by just setting the visibility property to hidden and the element will be hidden but it will still take up the same space as before.

Display Properties Examples

Display Property Task 1

Display Property Task 1

Display Property Task 2

Display Property Task 2

Display Property Task 3

Display Property Task 3

Display Property Task 4

Display Property Task 4

Take Your Free Live Demo Class Now

Enter Your DETAILS BELOW

To Get Complete Information or We Will Call You

We Will Send You the Course Fees Details In Below Number

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

Enter Your DETAILS BELOW TO take

free demo class