Display Property in CSS

Apr 4, 2023·

2 min read

Display Property in CSS

Here display properties refer to the display behaviour of an element. Three display property values can be specified in CSS to an element according to the required needs.

  1. Inline: In this, the width and height are adjusted according to the element. So, the width and height cannot be increases or decrease in this property. Denoted as display:inline;

  2. Block: In this, the width and height can be modified but the element takes the whole horizontal space of the screen. Denoted as display:block;

  3. Inline-block: In inline, the width and height cannot be modified whereas width and height can be defined in the block but face an issue while dealing with another element in the same line. So, to overcome form it inline-block property introduced in CSS3 which allows the developer to adjust width and height even with another element in the same line. Denoted as display:inline-block;

    Here is an example of the following display properties.

<!DOCTYPE html>
            <div class="inline">INLINE</div>
            <div class="inline">INLINE</div>
            <div class="block">BLOCK </div>
            <div class="block">BLOCK </div>
            <div class="inline-block">INLINE-BLOCK</div>
            <div class="inline-block">INLINE-BLOCK</div>



Beside this there is one extra display property which is usually used to hide the element by writing: display:none;

I hope you understood well by getting the difference between the display property values.