i

Learn HTML and CSS in 10 Days

Display Property Controls And Box Model?

Display

The display property controls the exact nature by which the elements get displayed (block-level elements, inline elements, etc.) on the web page. Every element comes with a pre-defined display property value. However, this value can be overwritten. There are a few values available for the display property, but the most popular ones are inline, block, inline-block, and none.

To change the display property of an element, we just need to select that element inside the CSS file and provide a new display property value to it. If you give a value of 'inline,' then that element will become inline-level, and if you give the value as 'block,' then it will be a block-level element.

Example –

p {

  display: inline;

}

p {

  display: block;

}

Things get fascinating with the ‘inline-block’ display value. With this value, the element gets some property of the block-level element (like, the element follows all Box Model properties) as well as some inline-level element (like, the element will not start itself from the new line).

Example –

p {

  display: inline-block;

}

If you are using the 'none' value, then the element will get hided completely, and the page will behave as if there is nothing in that area.

Learning how elements are shown and how to modify their display is genuinely significant, as the presentation of an element has got some restrictions with respect to the box model. Let’s see what the box model is such that we get known to these implications and the way to tackle them.

What is the Box Model?

As per the concept of Box Model, every element present on a web page behaves like a rectangular box having height, width, margins, borders, and padding.

Let’s understand how to work with the box model.