The CSS Rule
A CSS rule has two parts: a selector that targets HTML elements, and a declaration block with property–value pairs.
selector {
property: value;
property: value;
}h1 {
color: #D62828;
font-size: 32px;
margin-bottom: 16px;
}Key Points
- Each declaration ends with a semicolon
; - The declaration block is wrapped in curly braces
{ } - Property and value are separated by a colon
: - CSS is case-insensitive but convention is lowercase
Comments
/* This is a CSS comment */
p {
color: blue; /* inline comment */
}Use comments to label sections of your stylesheet — e.g.
/* === Header === */