Welcome to
ReDI School Munich - Spring 2021
But first...
There are three different ways of including css in our websites...
Inline
Internal
External
I want the main heading to be red and somewhat big...
They are the ones that let us find or SELECT the element that we want to style
/* I am a pink h1!
*/
#header { /* Only elements with id header */
color: pink;
}
/* Selects the anchor only when is hovered or focused */
a:hover, a:focus {
color: pink;
}
a:last-child {
color: blue;
}
a::before {
color: blue;
content: "Before content"
}
a::after {
color: blue;
content: "After content"
}
I am a paragraph!
div p {
color: blue;
}
Paragraph1
Paragraph2
div + p {
color: blue;
}
Paragraph1
I will be blue
This won't be blue
div ~ p {
color: blue;
}
Here is some content.
More content.
And here is a blue paragraph!
And another blue paragraph!
div > p {
color: red;
}
Paragraph1
I will be red
This won't be red
Inline ALWAYS wins!
If two rules are the same, the last one wins
div {
color: red;
}
div {
color: blue; /* I WIN! */
}
How does the browser calculate Specificity?
p {
color: red;
}
div p {
color: blue;
}
Which color am I?
p {
color: red;
}
div p {
color: blue;
}
.text {
color: red;
}
#text {
color: blue;
}
Which color am I?
.text {
color: red;
}
#text {
color: blue;
}
There are 4 main levels in the CSS Cascade
When is best to process it and manual overrides
Where does the rule come from?
Who won the race?
Where in the code is located?
Last one wins!!
Create a Button that looks like the image