CSS selectors and rules
- type
- syntax
- applies to
- every CSS rule, no exceptions
- inherits
- n/a
- common values
- property: value; pairs, one or more, semicolon-separated
Where it goes
In a .css file, or inside a <style> tag in <head>. Never written inside a tag like an attribute. That is the separate, more limited style="" form.
Example
p {
color: navy;
font-size: 18px;
}Common mistakes
- Forgetting the semicolon after a declaration. The browser usually recovers, but it can quietly drop the next declaration on the same line.
- A { with no matching }. Everything after it in the file can end up inside that rule by accident.