IntroDuction to Css

 

What Does Cascading mean?

Before we get into what cascading means lets take a look at three types of style sheets that influence the presentation of HTML documents and how they interact.

Cascading means that styles fall (or cascade) from one style sheet to another. The cascade is used to determine which style sheets will take precedence and be applied to the document. As the image displays the web page will most likely take precedence of and first follow the rules set by the author style sheet followed by the user style sheet and then the browser style sheet.

Specificity:

If you have two (or more) conflicting CSS rules that point to the same element, there are some basic rules that a browser follows to determine which one is most specific and therefore wins out.

The actual specificity of a group of nested selectors takes some calculating. Basically, you give every id selector ("#whatever") a value of 100, every class selector (".whatever") a value of 10 and every HTML selector ("whatever") a value of 1. Then you add them all up and hey presto, you have the specificity value.

So if all of these examples were used, div p.tree (with a specificity of 12) would win out over div p (with a specificity of 2) and body #content .alternative p would win out over all of them, regardless of the order.

 

 

Why Use CSS?