Goal: Master block, inline, and inline-block display properties by building visual layouts.
Time: 60-90 minutes
Tools needed: Text editor and web browser
Submission: Create a file named building-blocks.html
| Property | Behavior | Width/Height | Margins |
|---|---|---|---|
| display: block; | Takes full width, starts new line | โ Can set | โ All sides work |
| display: inline; | Flows with text, no line break | โ Cannot set | Only left/right work |
| display: inline-block; | Flows inline but acts like block | โ Can set | โ All sides work |
Each takes full width and stacks vertically
They flow horizontally like text
Flow horizontally but can have width/height like blocks
Create 3 colored blocks using display: block;
display: block;
<div style="display: block; background-color: #667eea;
height: 100px; padding: 20px; margin: 10px 0;
color: white;">
Block 1
</div>
Create a paragraph with inline highlighted words.
display: inline;
<p style="font-size: 18px;">
I love <span style="display: inline; background-color: yellow;
padding: 3px;">HTML</span> and
<span style="display: inline; background-color: lightblue;
padding: 3px;">CSS</span>.
</p>
I love HTML and CSS and JavaScript for web development.
Create a row of buttons using display: inline-block;
display: inline-block;
<div style="display: inline-block; width: 150px; height: 50px;
background-color: #667eea; color: white;
text-align: center; line-height: 50px;
margin: 5px; border-radius: 5px;">
Button 1
</div>
Create a grid of product cards using display: inline-block;
display: inline-block;
<div style="display: inline-block; width: 250px;
border: 2px solid #ddd; padding: 20px;
margin: 10px; border-radius: 8px;
vertical-align: top;">
<h3 style="margin-top: 0; color: #667eea;">Product 1</h3>
<div style="width: 100%; height: 150px;
background-color: #e9ecef; margin: 10px 0;
text-align: center; line-height: 150px;
color: #666;">
Image Placeholder
</div>
<p>Quality product description here.</p>
<p style="color: #28a745; font-size: 24px;
font-weight: bold;">$49.99</p>
</div>
<!-- Repeat 5 more times with different products -->
Quality product description here.
$49.99
Quality product description here.
$59.99
Quality product description here.
$39.99
Create a page header combining all three display types.
<div style="display: block; background-color: #2c3e50;
padding: 20px;">
<!-- Logo -->
<div style="display: inline-block; width: 100px;
height: 100px; background-color: #667eea;
color: white; text-align: center;
line-height: 100px;">
LOGO
</div>
<!-- Nav Links -->
<div style="display: inline-block; margin-left: 50px;">
<a href="#" style="display: inline-block; color: white;
padding: 10px 20px; margin: 0 5px;">
Home <span style="display: inline; background-color: red;
padding: 2px 6px; border-radius: 10px;
font-size: 12px;">New</span>
</a>
</div>
</div>
Build a mini dashboard combining everything.
Answer these in comments in your HTML:
| Task | Points |
|---|---|
| Task 1: Color Blocks | 15 |
| Task 2: Inline Tags | 15 |
| Task 3: Button Row | 20 |
| Task 4: Card Grid | 25 |
| Task 5: Mixed Layout | 25 |
| Task 6: Dashboard | 30 |
| Understanding Questions | 10 |
| Total | 140 points |
vertical-align: top; on inline-block elements to align them properlytext-align: center; to parent for centering inline-block children