filmov
tv
CSS Basics (Part2) — Cascades
Показать описание
Today we look at a few (not all) of the ways that styles "cascade".
-------------------------------------------------
# 1
The first way stylesheets cascade, is that a single style can effect multiple HTML elements.
For example, let's say we have a few paragraph tags. Then let's say that we change our mind and we want all of our paragraphs on our website to be red. We can write one simple style to do this.
All of the elements that match the criteria of that style rule, will be effected by it. In this case, every paragraph. Notice That our list was not effected.
# 2
The second way that stylesheets cascade is similar to the first, but reversed. That is, one html element can be effected by many styles, in different ways, all at the same time.
Let's say we write a general style that makes all of our paragraphs have red text, and then later on we target the first paragraph and make it 18px large. It is now both red and 18px large. See? Cascading.
# 3
The third way they cascade is what allows us to use the powers of stylesheets to make large scale websites. In this way, one stylesheet can be applied to many pages across a website, or even multiple sites!
For example, on my website I have many pages, on all of those pages I have the same header. This is super easy to accomplish with CSS. I just link all the HTML pages to that same style sheet.
-------------------------------------------------
# 1
The first way stylesheets cascade, is that a single style can effect multiple HTML elements.
For example, let's say we have a few paragraph tags. Then let's say that we change our mind and we want all of our paragraphs on our website to be red. We can write one simple style to do this.
All of the elements that match the criteria of that style rule, will be effected by it. In this case, every paragraph. Notice That our list was not effected.
# 2
The second way that stylesheets cascade is similar to the first, but reversed. That is, one html element can be effected by many styles, in different ways, all at the same time.
Let's say we write a general style that makes all of our paragraphs have red text, and then later on we target the first paragraph and make it 18px large. It is now both red and 18px large. See? Cascading.
# 3
The third way they cascade is what allows us to use the powers of stylesheets to make large scale websites. In this way, one stylesheet can be applied to many pages across a website, or even multiple sites!
For example, on my website I have many pages, on all of those pages I have the same header. This is super easy to accomplish with CSS. I just link all the HTML pages to that same style sheet.