Learn how CSS works from the ground up. Understand CSS syntax, selectors, cascade, inheritance, and specificity with simple explanations and examples.
CSS Basics Explained: Syntax, Selectors, Cascade & Specificity
In this lesson, you’ll learn the most important core concepts of CSS that control how styles actually work:
CSS syntax, selectors, cascade, inheritance, and specificity .
If CSS ever felt random or frustrating, it’s usually because one of these rules was unclear.
Once you understand them, CSS becomes predictable, logical, and easy to debug .
Info!
Every CSS framework (Bootstrap, Tailwind, custom design systems) is built on these exact fundamentals.
1. CSS Syntax (How CSS Is Written)
CSS is written using rules . A rule tells the browser what to select and how to style it .
selector {
property: value;
}
Example rule:
✏️ Edit ▶ Run <!DOCTYPE html>
<html>
<head>
<style>
p {
color: blue;
font-size: 18px;
}
</style>
</head>
<body>
<p>This paragraph is styled using CSS syntax.</p>
</body>
</html>
Here:
p is the selector color and font-size are properties blue and 18px are values Success! CSS syntax is simple. Most proble…