Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views1 page

Chapter 2

Chapter 3 discusses the concepts of specificity, inheritance, and the cascade in CSS. It explains how these mechanisms interact when applying styles to elements, emphasizing that specificity determines which styles take precedence. The chapter also highlights the importance of understanding these concepts for effective CSS styling.

Uploaded by

deathbymothballs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Chapter 2

Chapter 3 discusses the concepts of specificity, inheritance, and the cascade in CSS. It explains how these mechanisms interact when applying styles to elements, emphasizing that specificity determines which styles take precedence. The chapter also highlights the importance of understanding these concepts for effective CSS styling.

Uploaded by

deathbymothballs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CHAPTER 3

Specificity and the Cascade

Chapter 2 showed how document structure and CSS selectors allow you to apply a
wide variety of styles to elements. Knowing that every valid document generates a
structural tree, you can create selectors that target elements based on their ancestors,
attributes, sibling elements, and more. The structural tree is what allows selectors to
function and is also central to a similarly crucial aspect of CSS: inheritance.
Inheritance is the mechanism by which some property values are passed on from an
element to its descendants. When determining which values should apply to an ele‐
ment, a user agent must consider not only inheritance but also the specificity of the
declarations, as well as the origin of the declarations themselves. This process of con‐
sideration is what’s known as the cascade. We will explore the interrelation between
these three mechanisms—specificity, inheritance, and the cascade—in this chapter,
but the difference between the latter two can be summed up this way: choosing the
result of h1 {color: red; color: blue;} is the cascade; making a span inside the
h1 blue is inheritance.
Above all, regardless of how abstract things may seem, keep going! Your perseverance
will be rewarded.

Specificity
You know from Chapter 2 that you can select elements using a wide variety of means.
In fact, it’s possible that the same element could be selected by two or more rules,
each with its own selector. Let’s consider the following three pairs of rules. Assume
that each pair will match the same element:
h1 {color: red;}
body h1 {color: green;}

h2.grape {color: purple;}

97

You might also like