Every visual decision on the web comes down to CSS. This is where you learn to control it — not guess at it.
What You'll Learn
The building blocks every front-end developer uses every single day:
📝 CSS Rule Anatomy — how selectors, properties, and values fit together into rules that style your page
🔗 3 Ways to Add CSS — inline, internal, and external stylesheets, and when to use each
🎯 Selectors & Specificity — element, class, and ID selectors, plus how browsers decide which rule wins when styles conflict
📦 The Box Model — the single most important concept in CSS; understanding how margin, border, padding, and content interact
🎨 Color Formats — named colors, hex codes, RGB, and RGBA for transparency
🛠️ The Professional Reset — the one box-sizing: border-box rule every real project starts with, and why it saves you from layout headaches
Why This Matters
Most CSS frustration — elements the wrong size, layouts breaking unexpectedly, styles not applying — comes from not understanding the Box Model and specificity. Once these two concepts click, CSS stops feeling like guesswork and starts feeling like a tool you control.
Before You Watch
Make sure you've completed Lecture 2: HTML Foundations. You should be comfortable with:
Writing HTML tags and nesting elements
Understanding parent/child relationships in HTML
The basic structure of a webpage (head, body, etc.)
📎 The cheatsheet for this lecture is attached below the video. The Box Model diagram and the Common Properties Quick Reference table are worth keeping open as you code along!
CSS Fundamentals & The Box Model Cheatsheet
Quick reference for all CSS concepts covered in Lecture 3.
CSS Rule Anatomy
Every CSS rule follows this structure:
1selector{
2property: value;
3property: value;
4}
Example:
1h1{
2color:#E04A7A;
3font-size:32px;
4text-align: center;
5}
Key: selector → targets HTML elements | property → what to change | value → how to change it
3 Ways to Add CSS
Method
Syntax
When to Use
Inline
<p style="color: red;">
Quick testing only — avoid in production
Internal
<style> in <head>
Single-page projects, learning
External
<link rel="stylesheet" href="style.css">
Production — best practice
Selector Types Reference
Selector
Syntax
Example
Specificity
Element
tagname
p { }
0-0-1
Class
.classname
.highlight { }
0-1-0
ID
#idname
#header { }
1-0-0
Grouping
sel1, sel2
h1, h2 { }
Individual
Pseudo-class
sel:state
a:hover { }
0-1-1
Remember: Dot . goes in CSS, NOT in HTML!
1<!-- HTML — no dot -->
2<pclass="highlight">Text</p>
1/* CSS — dot required */
2.highlight{color:red;}
Specificity Scoring (0-0-0)
1Inline styles → 1-0-0-0(highest — avoid!)
2ID selectors → 0-1-0-0
3Class selectors → 0-0-1-0
4Element selectors→ 0-0-0-1(lowest)
Rules:
Higher specificity ALWAYS wins
Equal specificity → last rule wins (the cascade)
!important overrides everything (never use it)
Example:
1p{color:blue;}/* 0-0-1 */
2.special{color:red;}/* 0-1-0 ← WINS */
3#unique{color:green;}/* 1-0-0 ← WINS over both */