HTML
  Home arrow HTML arrow Page 3 - Cascading Style Sheets: The How and the Wh...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Cascading Style Sheets: The How and the Why
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2001-11-24

    Table of Contents:
  • Cascading Style Sheets: The How and the Why
  • Cascading whats?
  • An example of an inline style sheet
  • An example of an external style sheet
  • A more advanced style sheet example
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Cascading Style Sheets: The How and the Why - An example of an inline style sheet


    (Page 3 of 6 )

    Style sheets can either be inline (included as part of a HTML document), or, referenced externally (Contained in a separate file and referenced from the HTML document). Inline style sheets are contained wholly within a HTML document and will only change the look and layout of that HTML file.

    Open your favorite text editor and enter the following code. Save the file as stylesheet.html and open it in your browser:

    <html>

    <head>

    <title> Cascading Style Sheet Example </title>

    <style>

    h1

    {

    color: #636594;

    font-family: Verdana;

    size: 18pt;

    }

    </style>

    </head>

    <body>

    <h1>This is one big H1 tag!</h1>

    </body>

    </html>



    When you fire up your browser, you should get a page that looks like this:

    A sample style sheet with custom H1 attributes

    Let's step through the style code step by step.

    Firstly, we have a pretty standard HTML header. The page starts with the <html> tag followed by the <head> tag. Next, we use a standard <title> tag to set the title of the page we are working with.

    Notice, though, that before the <head> tag is closed, we have our <style> tag, its contents, and then the closing </style> tag.

    <style>

    h1

    {

    color: #636594;

    font-family: Verdana;

    size: 18pt;

    }

    </style>


    When you add the style sheet code inline (as part of the HTML document), it must be bound by <style> and </style> tags respectively. Our example is working with the <h1> tag. We are changing three attributes of the <h1>'s style: the text color (color), the font that any <h1> tags on the page will be displayed in (font-family), and lastly, the size of the font (size).

    The code between the { and } are known as the declarations. Our sample code has three. Try changing the hexadecimal value of the color attribute to #A00808 and then save and refresh the page. It should look like this:

    Our style sheet example now appears with red text!

    More HTML Articles
    More By Mitchell Harper


     

    HTML ARTICLES

    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset
    - Building Single Row Database Forms with HTML
    - Introduction to Database Forms with HTML
    - Another Look at Animation of Geographical Ma...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT