DEV Community

Nanthini Ammu
Nanthini Ammu

Posted on

CSS Part 3

Display Property (block, inline, inline-block):

  • It controls how an element is shown on the page.

Block:

  • Element takes full width.
  • Starts on a new line.
<div>Block 1</div>
<div>Block 2</div>

div {
    display: block;
    background-color: lightblue;
}
Enter fullscreen mode Exit fullscreen mode

Inline:

Elements stays in same line.
Takes only required width.

<span>Span 1</span>

span {
    display: block;  
    background-color: lightgreen;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)