BCA Student Stories & UpdatesLive
CSS Display Property: Block, Inline, Inline-Block & None
The `display` property is the fundamental switch controlling how an element participates in CSS formatting contexts.
Day 12 Step-by-Step Practical Flow
🎯1. What You Will Learn Today
CSS Display Property: Block, Inline, Inline-Block & None — Comprehensive Practical Guide
Har concept ko visual mental models, code anatomy aur practical industry tips ke sath samjhein.
The `display` property is the fundamental switch controlling how an element participates in CSS formatting contexts.
"Block is like a full-width parking spot for a bus. Inline is like words flowing on a typed line. Inline-block is like a picture stamp glued right inside a sentence."
👨🏫3. Teacher Demonstration Code
Converting list items into interactive inline-block pill buttons.
<style>
.tag-item {
display: inline-block;
padding: 8px 16px;
background: #000000;
color: #ffffff;
border-radius: 20px;
margin-right: 8px;
font-size: 13px;
font-weight: bold;
}
</style>
<span class="tag-item">HTML5</span>
<span class="tag-item">CSS3</span>
<span class="tag-item">JavaScript</span>2. Hands-On Practical Lab: Follow Instructions in VS Code
Code like a professional software engineer! Follow the step-by-step instructions below in Visual Studio Code (VS Code) on your PC, test your output locally, and push to GitHub.
Day 12 Practical Task Test Studio
Add `display: inline-block;` to .btn-link.
Add `padding: 8px 18px;` and `margin-right: 10px;`.
Spot the Bug: Width Ignored on Inline Anchor Tag
Tap or click on the exact line below that contains the error:
Click any code linea.hero-btn { display: inline; width: 220px; height: 50px; padding: 10px;}Senior Developer Forensic Analysis:
Elements with display: inline strictly ignore width and height CSS properties according to the W3C CSS specification.
📝Independent Practice: Assignment
📄 nav-display.htmlHomework Task: Tech Skill Badge Cloud
- •Create folder `day-12` with `index.html`.
- •Create a skill cloud section containing 8 developer skill badges (e.g. Linux, Git, HTML, C, Python).
- •Style each badge with `display: inline-block`, distinct background colors, and `cursor: pointer`.
- •Add a secret badge with class `.hidden-badge` styled with `display: none`.
Open Visual Studio Code on your PC (code .), create nav-display.html, paste this complete step-by-step verified code, test in your browser, and push to your GitHub repo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BCA Day 12 - CSS Display Modes Comparison</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #0f172a;
color: #f1f5f9;
padding: 32px 16px;
line-height: 1.6;
}
.wrapper {
max-width: 720px;
margin: 0 auto;
background: #1e293b;
padding: 28px;
border-radius: 16px;
border: 1px solid #334155;
}
h1 { font-size: 22px; color: #38bdf8; margin-bottom: 16px; }
.demo-section {
background: #0f172a;
padding: 16px;
border-radius: 12px;
margin: 16px 0;
border: 1px solid #334155;
}
.demo-title { font-size: 13px; font-weight: bold; color: #fbbf24; margin-bottom: 8px; }
/* Display: inline (No width/height respect) */
.inline-item {
display: inline;
background: #2563eb;
color: white;
padding: 4px 8px;
margin: 4px;
border-radius: 4px;
}
/* Display: block (Takes full width) */
.block-item {
display: block;
background: #059669;
color: white;
padding: 8px 12px;
margin: 6px 0;
border-radius: 6px;
}
/* Display: inline-block (Horizontal flow + accepts width/height) */
.inline-block-item {
display: inline-block;
width: 130px;
height: 40px;
line-height: 40px;
text-align: center;
background: #7c3aed;
color: white;
margin: 4px;
border-radius: 8px;
font-weight: 600;
}
/* Display: none (Completely hidden from flow) */
.hidden-item {
display: none;
}
</style>
</head>
<body>
<div class="wrapper">
<h1>CSS Display Property in Action</h1>
<div class="demo-section">
<div class="demo-title">1. Inline (Flows like text, ignores width/height):</div>
<span class="inline-item">Item One</span>
<span class="inline-item">Item Two</span>
<span class="inline-item">Item Three</span>
</div>
<div class="demo-section">
<div class="demo-title">2. Block (Full width, stacks vertically):</div>
<div class="block-item">Block Item A (100% available width)</div>
<div class="block-item">Block Item B (Stacks onto next line)</div>
</div>
<div class="demo-section">
<div class="demo-title">3. Inline-Block (Horizontal navbar pills with precise width/height):</div>
<div class="inline-block-item">BCS-011</div>
<div class="inline-block-item">BCSL-013</div>
<div class="inline-block-item">BCS-012</div>
<div class="inline-block-item">FEG-02</div>
</div>
</div>
</body>
</html>🎓4. Viva Check: Mandatory Conceptual Test
What is the visual difference between `display: none` and `visibility: hidden`?
5. Mandatory Step: Push to GitHub to Unlock Next Lesson
Target Repo: html-css-projects
Exact GitHub Setup Guide & Expected Structure
Day 12 RequirementsFollow these exact folder and file names to prevent verification errors.
index.html: Avoid spaces or custom names like Alan Turing..html or Index.HTML. Linux/GitHub servers are strictly case-sensitive.day-12/ for today so you don't overwrite previous days.main.You are welcome to read all notes, inspect code snippets, and practice all exercises of Day 12 freely! To officially submit your GitHub repository and unlock subsequent days in your portfolio, please complete Day 11: CSS Box Model: Margin, Border, Padding & Content first.
Complete Day 11 First