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, 696 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: 03-How to Add Styles to a Webpage
    Prev: 01-Why Use CSS?
    02-Structure of CSS Rules
    Sankira.gif
    Author: * Sankira Qin - 15 Posts on this thread out of 1,340 Posts sitewide.
    Date: May 23, 2005 - 13:47

    Structure of CSS Rules

    A Cascading Style Sheet is made up of one or more rules describing how webpage elements should be displayed. Every rule consists of three parts: a selector and a property along with its value. Together, the property and its value make up a declaration.


    Rule structure

    Example 1 - Elements of a CSS Rule


    The selector is listed first. It indicates the element you want to affect. Example 1 uses the (header) HTML element. The declaration(s) goes to the right of the selector. All the declarations in a rule must be enclosed within a single pair of curly braces { }. In the syntax of a declaration, the property is always separated from its value using a colon (:). More than one declaration may be included in a rule, however, and these are separated from each other by a semi-colon (;). For example: h1 {color: #CC0000; font-weight: bold}.

    Property names are not case sensitive, so h1 and H1 are treated the same. However, XHTML and XML both require that all tags and attribute names be written in lowercase. So...for future compatibility, I suggest you just get used to using lowercase now. CSS doesn't care, and you won't have to try to remember when you can use which.

    The rule in Example 1 above tells the browser that all text inside the tag should be red.

    Coding Tip: The semi-colon isn't necessary after the last declaration in a list, but it doesn't hurt, either. Many people find it easier to simply include the semi-colon after every declaration, even if there is only one. Such as:

    h1 {color: #CC0000;}

    The choice is entirely up to the designer.


    NEXT: 03-How to Add Styles to a Webpage
    PREV: 01-Why Use CSS?
Rome - Rome, Season 1 - The Stolen Eagle


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