The weights of different selectors

All selectors are assigned a weight, and the heaviest selector takes precedence when conflicting CSS rules exist. It's natural when architecting a website that you have general styles that get overridden with more specific styles in different circumstances. In the global area at the top of the style sheet, a very broad style has been set for all paragraph elements:

p {  font-size: 16px;  line-height: 1.6;  margin-bottom: 20px;}

The font size is 16px. There is a line-height property of 1.6 and 20px of margin-bottom. Naturally, I might want to overwrite either line-height or margin-bottom under varying circumstances. Let's try and override that with a new rule set with a selector of .content-block p:

p { font-size: ...

Get Mastering CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.