CSS Basics covers the fundamental concepts every web developer should learn before
moving into layouts, responsive design, animations, Flexbox, Grid, and advanced CSS.
Understanding these concepts will help you write clean, maintainable, and scalable styles.
What You Will Learn in CSS Basics
How CSS syntax works.
Selectors, properties, and values.
CSS declarations and rule sets.
How CSS targets HTML elements.
CSS comments and organization.
Common beginner mistakes.
Best practices for writing maintainable CSS.
CSS Basics Cheatsheet
Concept
Example
Purpose
Selector
h1
Selects HTML elements.
Property
color
Defines what style changes.
Value
blue
Defines the style setting.
Declaration
color: blue;
Property-value pair.
Rule Set
h1 { color: blue; }
Complete styling rule.
Class Selector
.card
Styles reusable components.
ID Selector
#header
Styles one unique element.
Comment
/* comment */
Adds documentation.
External CSS
style.css
Stores reusable styles.
Media Query
@media
Responsive design.
CSS Syntax
CSS syntax consists of selectors and declaration blocks. The selector identifies
which HTML element should be styled, while the declaration block contains style rules.
selector {
property: value;
}
Example
h1 {
color: blue;
font-size: 2rem;
}
In this example:
h1 is the selector.
color and font-size are properties.
blue and 2rem are values.
Selectors, Properties, and Values
Every CSS rule contains these three building blocks.
p {
color: #333333;
}
Part
Value
Selector
p
Property
color
Value
#333333
CSS Rule Set
A CSS rule set is a complete styling instruction consisting of a selector and one
or more declarations.