Selectors and specificity
Selectors
- selector: a keyword used to query your html tags, classes, ids -- (the last two are html attributes)
- rules: the style attributes you are going to set
Basic Selectors
Complex Selectors are
Specificity
- not all selectors are created equal
- tags -> 1
- classes -> 10
- ids -> 100
- you can calculate the specificity of a selector by adding up all the values
- ie: body.my-class#my-id has a specificity of: 111
- body -> 1
- .my-class -> 10
- #my-id -> 100
- so 1 + 10 + 100 = 111
Practice
- this
- this
- this..?