SunQuest
 
       Style Sheets
  Home arrow Style Sheets arrow Page 2 - Learn CSS: Introduction to Inheritance, Sp...
IBM developerWorks
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  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
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? 
STYLE SHEETS

Learn CSS: Introduction to Inheritance, Specificity, and Cascade
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2005-07-18

    Table of Contents:
  • Learn CSS: Introduction to Inheritance, Specificity, and Cascade
  • The Style Tag
  • Importing Style Sheets
  • CSS Inheritance

  • 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

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    Learn CSS: Introduction to Inheritance, Specificity, and Cascade - The Style Tag


    (Page 2 of 4 )

    Inline styling (through the Style attribute) is limited because you can't use selectors, you simply apply certain declarations on the current element (the element that declared the Style attribute). The Style tag, on the other hand, is unlimited because you can define almost anything you define in the .css external file. You place the Style tag (which we used to call the embedded style sheet) in the <head> section after the <title> element, as in the following HTML code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>CSS Structure</title>
        <style type='text/css'>
          body
          {
            font-family: Arial;
            font-size: 1.1em;
          }
          div
          { 
            color: white; 
            background-color: black;
            height: 30px;
          } 
        </style>
      </head>
      <body>
        <div>
          This is a div element with an inline style
        </div>
      </body>
    </html>

    Older browsers don't support CSS, so when you browse a Web page that has an embedded style sheet (using the Style tag) it will cause problems. The solution to this problem is to surround the CSS rules inside the opening <style> and the closing</style> with an HTML comment. This makes sense because a comment text will be escaped. This rule applies to both older and modern browsers with only one trick. The CSS engine in the modern browsers understands that CSS rules may be surrounded by an HTML comment inside the Style tag, so it will apply the styles to the document. So if we surrounded the above CSS rules with an HTML comment it will look like the following code:

    <style type='text/css'>
    <!--
    body
    {
      font-family: Arial;
      font-size: 1.1em;
    }
    div
    {
      color: white;
      background-color: black;
      height: 30px;
    }
    -->
    </style>

    More Style Sheets Articles
    More By Michael Youssef


     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway