Aims:
inheritance in CSS
a property applied to an element is also automatically applied to the element's descendants
<p>I like the <i>Vombatus ursinus</i> family</p>
p
{
color: red;
}
i
{
color: blue;
}
h1
{
color: red;
}
h1
{
font-style: italic;
}
h1
{
color: red;
}
h1
{
color: blue;
}
section
{
color: blue;
}
#instructions
{
color: green;
}
in mojitos.html
h3
{
color: blue !important;
}
!important one wins!important…!important rules from user stylesheets!important rules from author stylesheetsClass exercise: Which is the more specific in each of these pairs of rules
i
{
color: blue;
}
.cocktail
{
color: green;
}
nav li
{
color: yellow;
}
li
{
color: gray;
}
#instructions b
{
color: teal;
}
ol li b
{
color: purple;
}
h1
{
color: red;
}
h1
{
color: blue;
}
In the Instructions section of mojitos.html, what colour will the word "crush" be and what colour will the rest of that list item be?
#instructions
{
color: green;
}
li > b
{
color: red;
}
section b
{
color: blue;
}
section
{
color: yellow;
}
nav > ul > li
{
color: red;
}
nav li li
{
color: blue;
}
nav li
{
color: red;
}
nav li li
{
color: blue;
}