CSS How It Works
Understand how CSS connects with HTML, how browsers read CSS rules, and why styles sometimes apply and sometimes don’t.
David Miller
November 24, 2025
8.0k194
CSS works by selecting HTML elements and applying styles to them.
A CSS rule has three parts:
- selector
- property
- value
Basic rule structure
h1 {
color: red;
}
- h1 → selector
- color → property
- red → value
How browser reads CSS
- Browser loads HTML
- Browser loads CSS
- Browser matches selectors
- Browser paints the page
Example
Try it yourself! Edit the HTML and CSS below:
<h1>Welcome</h1>
<p>This is a website</p>
h1 {
color: green;
}
p {
color: gray;
}
Result:
- heading is green
- paragraph is gray
Try changing the colors in the CSS tab to see the changes instantly!
Common beginner confusion
“Why my CSS not applying?”
Usually because:
- wrong selector
- typo in class name
- CSS file not linked
Remember
- CSS does not change HTML
- CSS only changes appearance
- Browser applies rules step by step
#CSS#Beginner#Core