The CSS cascade

Derek Bridge

Department of Computer Science,
University College Cork

The CSS cascade

Aims:

Inheritance

Over-riding inheritance

Conflicts

Conflicts

Resolving conflicts: importance and origin

Resolving conflicts: importance

Resolving conflicts: origin

Resolving conflicts: specificity

Resolving conflicts: specificity

Class 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;
}

Resolving conflicts: ordering

Resolving conflicts: the cascade

Class exercise

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;
}

Conflicts are not irrelevant, just because they're difficult!

Getting help