We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 22,508 times

Contents

Related Categories

Using Cascading Style Sheets (CSS) - Specifying Styles within an HTML Document

gez

Specifying Styles within an HTML Document

Styles specified within the document may either apply to the whole document, or a tag contained in the document.

Applying the Style to the whole Document

To apply a style to the whole document, the style information must be placed in the head of the document. The style information is a set of rules that determine how the HTML document is formatted. The following example sets the style for links so they're not underlined and have a colour of black, that turn blue when the mouse is moved over the link. The actual syntax for the style is explained later in this tutorial.

<head>
    <title>Title for this Page</title>
    <style type="text/css">
        a
        {
            text-decoration:none;
            color:#00c;
            background:transparent;
        }
        a:hover
        {
            color:#900;
            background:transparent;
        }
    </style>
</head>

Applying the Style to a Tag

Applying a style directly to a tag is called an inline style. To apply a style to a tag, use the style attribute of the particular tag you want to apply the style to. The following example sets the contents of a cell in a table so that the background colour is light blue.

<td style="background-color:#39C;">content of cell</td>

Further styles maybe added, separated by a semicolon.

<td style="background-color:#39C;font-size:small;">content of cell</td>

I'm available for contract work. Please visit Juicify for details.

Comments

  • CSS basics are good..Watch out for the Extreme CSS

    Posted by dc on 30 Jul 2003

    This is a good tutorial as it covers the basics.

    Nevertheless, readers should know that CSS can be taken to the extreme and should know the other side of the story in regards to fully integrated CS...