Declaration Blocks
Declaration blocks begin with a left curly brace, {, and end with a right curly brace, }. They contain zero or more declarations separated by semicolons:
h2 {
color: #666;
}
A declaration block is always preceded by a selector. We can combine multiple rules that have the same selector into a single rule. Consider these rules:
h2 {
color: #666;
}
h2 {
font-weight: bold;
}
They’re equivalent to the rule below:
h2 {
color: #666;
font-weight: bold;
}
Although the last semicolon within a declaration block is optional, it’s good practice to include it, as it’ll help you avoid syntax errors in the future. As you start to add declarations to a block, it’s all too easy to forget the semicolon.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.
