📘 DAY 12: HTML CSS
1️⃣ What is CSS?
CSS stands for Cascading Style Sheets.
CSS is used to:
Style HTML elements
Control layout and design
Improve user experience
👉 HTML = structure
👉 CSS = design
2️⃣ Why Do We Need CSS?
Without CSS:
Pages look plain
No colors or layout
Poor readability
With CSS:
✔ Attractive design
✔ Consistent styling
✔ Easy maintenance
3️⃣ Ways to Apply CSS in HTML
There are three ways to apply CSS:
Inline CSS
Internal CSS
External CSS
4️⃣ Inline CSS
Inline CSS is written inside the HTML element using the style attribute.
Syntax:
Example:
✔ Advantages
Quick styling
Easy for beginners
❌ Disadvantages
Not reusable
Messy code
Not recommended for large pages
5️⃣ Internal CSS
Internal CSS is written inside the <style> tag in the <head> section.
Syntax:
Example:
✔ Advantages
Better than inline
Styles multiple elements
❌ Disadvantages
Not reusable across pages
6️⃣ External CSS
External CSS is written in a separate .css file and linked to HTML.
Step 1: Create CSS file (style.css)
Step 2: Link CSS file in HTML
✔ Advantages
✔ Reusable
✔ Clean HTML
✔ Best practice
✔ Used in real projects
❌ Disadvantages
Slightly complex for beginners
7️⃣ CSS Selectors (Basic)
Selectors choose which HTML elements to style.
Element Selector
Class Selector
HTML:
ID Selector
HTML:
8️⃣ Priority Order of CSS (Very Important)
If multiple CSS types are applied:
1️⃣ Inline CSS (Highest priority)
2️⃣ Internal CSS
3️⃣ External CSS (Lowest priority)
9️⃣ Comparison Table
| Feature | Inline | Internal | External |
|---|---|---|---|
| Location | Inside tag | Inside <head> | Separate file |
| Reusable | ❌ | ❌ | ✅ |
| Best practice | ❌ | ⚠️ | ✅ |
| Used in real projects | ❌ | ❌ | ✅ |
🔟 Common Beginner Mistakes
❌ Forgetting to link CSS file
❌ Wrong file path
❌ Mixing inline everywhere
❌ Using same id multiple times
1️⃣1️⃣ Practice Example
✔ Create index.html
✔ Create style.css
✔ Apply styles to heading and paragraph
1️⃣2️⃣ Interview / Viva Questions
What is CSS?
Types of CSS?
Difference between inline and external CSS?
Which CSS has highest priority?
Why is external CSS recommended?
1️⃣3️⃣ Summary
CSS styles HTML pages
Three types: inline, internal, external
External CSS is best practice
CSS selectors target elements
Proper CSS improves design & maintenance
📘 DAY 12: HTML CSS
1️⃣ What is CSS?
CSS stands for Cascading Style Sheets.
CSS is used to:
Style HTML elements
Control layout and design
Improve user experience
👉 HTML = structure
👉 CSS = design
2️⃣ Why Do We Need CSS?
Without CSS:
Pages look plain
No colors or layout
Poor readability
With CSS:
✔ Attractive design
✔ Consistent styling
✔ Easy maintenance
3️⃣ Ways to Apply CSS in HTML
There are three ways to apply CSS:
Inline CSS
Internal CSS
External CSS
4️⃣ Inline CSS
Inline CSS is written inside the HTML element using the style attribute.
Syntax:
Example:
✔ Advantages
Quick styling
Easy for beginners
❌ Disadvantages
Not reusable
Messy code
Not recommended for large pages
5️⃣ Internal CSS
Internal CSS is written inside the <style> tag in the <head> section.
Syntax:
Example:
✔ Advantages
Better than inline
Styles multiple elements
❌ Disadvantages
Not reusable across pages
6️⃣ External CSS
External CSS is written in a separate .css file and linked to HTML.
Step 1: Create CSS file (style.css)
Step 2: Link CSS file in HTML
✔ Advantages
✔ Reusable
✔ Clean HTML
✔ Best practice
✔ Used in real projects
❌ Disadvantages
Slightly complex for beginners
7️⃣ CSS Selectors (Basic)
Selectors choose which HTML elements to style.
Element Selector
Class Selector
HTML:
ID Selector
HTML:
8️⃣ Priority Order of CSS (Very Important)
If multiple CSS types are applied:
1️⃣ Inline CSS (Highest priority)
2️⃣ Internal CSS
3️⃣ External CSS (Lowest priority)
9️⃣ Comparison Table
| Feature | Inline | Internal | External |
|---|---|---|---|
| Location | Inside tag | Inside <head> | Separate file |
| Reusable | ❌ | ❌ | ✅ |
| Best practice | ❌ | ⚠️ | ✅ |
| Used in real projects | ❌ | ❌ | ✅ |
🔟 Common Beginner Mistakes
❌ Forgetting to link CSS file
❌ Wrong file path
❌ Mixing inline everywhere
❌ Using same id multiple times
1️⃣1️⃣ Practice Example
✔ Create index.html
✔ Create style.css
✔ Apply styles to heading and paragraph
1️⃣2️⃣ Interview / Viva Questions
What is CSS?
Types of CSS?
Difference between inline and external CSS?
Which CSS has highest priority?
Why is external CSS recommended?
1️⃣3️⃣ Summary
CSS styles HTML pages
Three types: inline, internal, external
External CSS is best practice
CSS selectors target elements
Proper CSS improves design & maintenance

