0% completed
In CSS, the display
property determines how elements are rendered on the page. The three most common display types are block, inline, and inline-block. Each type affects the layout, flow, and behavior of the elements. Understanding these display types helps you structure your page content effectively.
Follow the code block below to set the display property in CSS:
/* Set element as block */ display: block; /* Set element as inline */ display: inline; /* Set element as inline-block */ display: inline-block;
Explanation:
In this example, we demonstrate the difference between block and inline elements using <div>
for block and <span>
for inline.
Explanation:
<div>
with the class .block-element
takes up the full width and starts on a new line.<span>
with the class .inline-element
only occupies the space it needs and flows with the surrounding text.In this example, we style elements as inline-block to show how they combine the traits of both block and inline elements. Multiple inline-block elements can sit next to each other, but they also allow you to set dimensions and spacing.
Explanation:
<div>
with the class .inline-block-element
can sit on the same line, similar to inline elements.This lesson shows you how to use the display
property with block, inline, and inline-block values to control element layout. Using these properties effectively will help you build flexible and organized page structures.
.....
.....
.....