Welcome
Arachne's Web
A group focused on serving the AW community by providing help and discussion on topics such as HTML, CSS, web design, homesite decorating, netiquette and issues important to web artists.

Arachne's Web Academy (- threads, 693 posts)
    Tutorials - Cascading Style Sheets (47 posts)
    Social Thread

    Stylesheets let you control the look of your pages like never before, right down to the spacing between letters. Here is where we'll learn how it's all done. ...
    8 Members have made 32 Posts here to date.
    Google
    AncientWorlds.net Web
    Next: 09-Classes
    Prev: 07-Style Precedence: the Technical Approach
    08-Inheritance
    Sankira.gif
    Author: * Sankira Qin - 15 Posts on this thread out of 1,337 Posts sitewide.
    Date: May 28, 2005 - 17:28

    The Cascade Revisited

    We've talked about specificity and we've talked about selector "weights". Now, let's look at the relatively simple concept of the document tree and inheritance.

    The Document Tree. HTML documents are built using a standard structure. At the top is the html element. Below that you have the head and body elements, and below those you have numerous other elements branching off. Those elements at the top of the tree are parent elements to those that fall beneath them (children).


    Rule structure
    Example 2 - HTML Document Tree Structure


    Inheritance. Bearing in mind that there are exceptions to every rule, a child element will generally acquire the properties of any element it is nested within (i.e., the parent tag). This is called inheritance. For example, if you define a color in the tag, most elements inside the body of the document will inherit the color you've defined. So:

    body {color: #ffffff; font: 16px Arial; background-color: #000000}

    will control the appearance of the entire screen. In some browsers, the font properties defined will also apply to teletype, preformatted, and headers, which might not be what you had in mind. Naturally, you can define a specific rule for the nested element to override the parent element's formatting.

    Most HTML tags have some properties already defined. For example, our old friend the tag is defined by default in HTML 4 as being bold in a very-large font and centered. When you redefine an element using CSS you don't lose any of the original attributes, unless you specifically change them. So:

    h1 { color: #003366; font-size: 14px; font-family: Papyrus; font-style: normal; }

    will affect the tag's bold in a very-large font properties, but it will STILL be centered, because this definition doesn't mention anything like "text-align: left" or "text-align: right". As another example, you might decide to define the tag to be green and italic,

    b { color: #00FF00; font-style: italic; }

    but unless you remember to change the font-weight (as in the example below), it will still be bold.

    b { color: #00FF00; font-style: italic; font-weight: normal; }

    At any rate, while not a huge problem, inheritance is just one more thing you need to keep in mind when creating your CSS rules.


    NEXT: 09-Classes
    PREV: 07-Style Precedence: the Technical Approach
Rome - Rome, Season 1 - The Stolen Eagle


Copyright 2002-2008 AncientWorlds LLC | Code of Conduct and Terms of Service | Contact Us! | The AncientWorlds Staff