Lecture 18 — CSS Display Property
Lecture 18 — CSS Display Property⌗
Instructor: Laksh Budhrani
Objectives⌗
By the end of this lesson, you will be able to:
- Understand the purpose of the CSS
displayproperty. - Differentiate between
block,inline, andinline-block. - Use
display: inline-blockto arrange elements next to each other.
Quick Recall: Previous Lectures Review⌗
Let’s quickly recall what we have learned so far!
HTML Tags⌗
| Tag | What It Does |
|---|---|
<div> | Groups larger sections of content |
<span> | Groups a small part of text |
CSS Properties⌗
| Property | What It Does |
|---|---|
background-color | Changes the background color |
font-family | Changes the font |
color | Changes the text color |
font-size | Changes the text size |
text-align | Aligns text horizontally |
text-decoration | Adds or removes decorative lines |
width | Controls the width of an element |
height | Controls the height of an element |
border | Adds an outline around an element |
padding | Adds space inside the border |
margin | Adds space outside the border |
Objective 1 — Understanding the display Property⌗
What it does: The CSS display property controls how HTML elements are arranged on a webpage.
For example, some elements appear one below another, while others appear next to each other.
We can use the display property to change how elements are arranged.
Objective 2 — Different Display Values⌗
a) display: block⌗
What it does: Displays an element on a new line. Block elements are placed one below another.
Example:
<div>First Box</div>
<div>Second Box</div>
div {
display: block;
background-color: lightblue;
width: 200px;
height: 60px;
}

b) display: inline⌗
What it does: Displays elements next to each other on the same line.
Inline elements take up only as much space as their content needs. The width and height properties do not work normally on inline elements.
Example:
<div>First Box</div>
<div>Second Box</div>
div {
display: inline;
background-color: lightblue;
width: 200px;
height: 60px;
}

c) display: inline-block⌗
What it does: Displays elements next to each other while still allowing us to control their width and height.
Example:
<div>First Box</div>
<div>Second Box</div>
div {
display: inline-block;
background-color: lightblue;
width: 200px;
height: 60px;
}

Remember: inline-block is especially useful when creating cards or sections that need to appear next to each other.
Quick Comparison⌗
| Display Value | Arrangement | Width & Height |
|---|---|---|
block | One below another | Work |
inline | Next to each other | Do not work normally |
inline-block | Next to each other | Work |
Side Note — Vertical Alignment⌗
Sometimes, elements using inline-block may not line up perfectly at the top, especially when they contain different amounts of text.
We can use vertical-align: top; to align their top edges.
div {
display: inline-block;
vertical-align: top;
}
Note: This is an additional CSS property. You do not need to use it for today’s activities.
Guided Activity — JP2 School Athletics!⌗
The Story⌗
John Paul II Catholic School wants to showcase its school sports on its website.
Let’s create three cards featuring:
- Basketball
- Soccer
- Volleyball
Your Task⌗
Open your existing jp2_website.html file.
Create three separate <div> containers, one for each sport. Use display: inline-block to place them next to each other.
Include a heading and a short description for each sport.
Style your containers using CSS properties learned so far.

Independent Activity — My Favorite Person: Career Highlights!⌗
Open your existing favorite_website.html file.
Your Task⌗
Create a section showcasing three important career highlights of your chosen person.
For example:
- Singer → Debut album, awards, concerts
- Actor → First movie, major awards, popular movies
- Athlete → Professional debut, championships, records
Use separate <div> containers for your three career highlights.
CSS Requirements:
- Use
display: inline-blockto arrange the containers next to each other. - Use
widthandheightto control their dimensions. - Use at least three other CSS properties learned in previous lectures.

Summary: CSS Display Property Learned Today⌗
| Property / Value | What It Does |
|---|---|
display: block | Places elements one below another |
display: inline | Places elements next to each other |
display: inline-block | Places elements next to each other while allowing width and height |