Goal: Practice using inline and block elements to understand their differences.
Time: 45-60 minutes
Tools needed: Text editor and web browser
Submission: Create a file named inline-block-practice.html
| Element | Description |
|---|---|
| <div> | Generic container |
| <p> | Paragraph |
| <h1> to <h6> | Headings |
| <ul>, <ol>, <li> | Lists |
| <header>, <footer>, <section> | Semantic elements |
| Element | Description |
|---|---|
| <span> | Generic inline container |
| <a> | Link |
| <strong>, <b> | Bold text |
| <em>, <i> | Italic text |
| <img> | Image |
Create the following and observe how they display:
<div style="background-color: lightblue; padding: 10px;">First Box</div>
<div style="background-color: lightgreen; padding: 10px;">Second Box</div>
<div style="background-color: lightyellow; padding: 10px;">Third Box</div>
<span style="background-color: lightblue; padding: 5px;">First Item</span>
<span style="background-color: lightgreen; padding: 5px;">Second Item</span>
<span style="background-color: lightyellow; padding: 5px;">Third Item</span>
Question: What's the main difference you notice?
Create a paragraph that uses BOTH block and inline elements:
<div style="border: 2px solid blue; padding: 15px;">
<h2>My Favorite Foods</h2>
<p>
I love <strong>pizza</strong> and <em>pasta</em>.
My favorite restaurant is <span style="color: red;">Italian Corner</span>.
</p>
<p>
Visit their website at <a href="#">www.italiancorner.com</a>
</p>
</div>
I love pizza and pasta. My favorite restaurant is Italian Corner.
Visit their website at www.italiancorner.com
Try setting width on block vs inline elements and see what happens:
<div style="width: 200px; background-color: lightblue; padding: 10px;">
I am 200px wide
</div>
<span style="width: 200px; background-color: lightcoral; padding: 10px;">
I tried to be 200px wide but I can't!
</span>
Question: Why doesn't the span respect the width?
Create a contact card using BOTH block and inline elements:
Create a simple navigation menu using block and inline elements:
<nav style="background-color: #2c3e50; padding: 15px;">
<a href="#" style="color: white; padding: 10px;">Home</a>
<a href="#" style="color: white; padding: 10px;">About</a>
<a href="#" style="color: white; padding: 10px;">Contact</a>
</nav>
Observe: The links (<a>) are inline, so they sit next to each other. The <nav> is block, so it takes full width.
Create a product card combining everything you've learned:
High-quality sound with noise cancellation.
Price: $99
✓ In Stock
Before submitting, make sure you have:
| Task | Points |
|---|---|
| Task 1: Observe the Difference | 10 |
| Task 2: Mixed Elements | 15 |
| Task 3: Width Experiment | 15 |
| Task 4: Contact Card | 25 |
| Task 5: Navigation Menu | 20 |
| Task 6: Product Card | 15 |
| Bonus Questions | 10 |
| Total | 110 points |