Skip to content

Instantly share code, notes, and snippets.

@melvinstanly
Last active September 30, 2021 10:06
Show Gist options
  • Save melvinstanly/e1851f59d5aeb1203912ed777a9ede4f to your computer and use it in GitHub Desktop.
Save melvinstanly/e1851f59d5aeb1203912ed777a9ede4f to your computer and use it in GitHub Desktop.
CSS Specificity
CSS rules have weight, and you should leverage those rules to correctly cascade styles.
element = 1 pt
class = 10 pt
id = 100 pt
inline = 1000 pt
An ID has a relatively high specificity of 100. A class has a specificity of 10.
#idname.classname - Now this selector has a specificity of 110.
div#idname.classname - Now this selector has a specificity of 111 (because an element has a specificity of 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment