✨ Blog Post: Day 7 – CSS Properties, Selectors & Units
📥 Download Notes + Code Examples (PDF)
👉 Click here to download Day 7 Notes (Add your actual PDF link)
📝 Introduction
Welcome to Day 7 of our 15-Day Web Development Series. Today, we dive into the fundamentals of CSS properties, selectors, and units — the essential tools that let you transform a plain HTML page into a visually engaging website.
🎯 What Are CSS Properties?
CSS properties are the rules you use to style HTML elements — including layout, color, spacing, and more.
✅ Syntax
🔍 Example
🧱 Common CSS Properties Explained
| Property | Purpose | Example |
|---|---|---|
color |
Sets the text color | color: red; |
background-color |
Sets the background color | background-color: lightblue; |
font-size |
Controls text size | font-size: 20px; |
padding |
Adds space inside the element | padding: 10px; |
margin |
Adds space outside the element | margin: 15px; |
border |
Creates a border around the element | border: 1px solid black; |
🎯 CSS Selectors
Selectors target HTML elements to apply CSS styles.
1. Universal Selector
Applies styles to all elements.
2. Element Selector
Targets all elements of a specific tag.
3. Class Selector
Targets elements with a specific class name.
4. ID Selector
5. Group Selector
📐 CSS Units: Absolute vs Relative
Understanding CSS units is key for responsive design.
📏 Absolute Units
-
px→ Pixels (fixed) -
cm,mm,in→ For print (rare in web)
📏 Relative Units
-
%→ Relative to parent element -
em→ Relative to parent’s font size -
rem→ Relative to root font size -
vw,vh→ Viewport width/height
💡 Example: Styled Box
🔹 HTML
🔹 CSS
🧪 Practice Task
-
Create a paragraph with
class="content"and style it with:-
Font-size:
18px -
Line-height:
1.5 -
Text-align:
justify
-
-
Create a
divwithid="wrapper"and style it with:-
Background:
#e0e0e0 -
Padding:
30px -
Border-radius:
10px
-
✅ Summary – Key Takeaways
-
CSS properties control how HTML looks.
-
Use selectors (
.class,#id,element) to apply styles effectively. -
Units like
px,%,em, andremaffect layout responsiveness. -
Group selectors and consistent units keep code clean.