Style Sheets
  Home arrow Style Sheets arrow Page 3 - CSS for the Newbie
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  
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? 
STYLE SHEETS

CSS for the Newbie
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2008-02-25

    Table of Contents:
  • CSS for the Newbie
  • Putting it all Together
  • Selectors...Unite!
  • Applying a Style to an Element with an Attribute
  • Doing It In Style

  • 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


    CSS for the Newbie - Selectors...Unite!


    (Page 3 of 5 )

    You can assign groups of selectors the same value in the following manner:


    h1,h2,h3,h4,h5,h6

    {

    font-family: “Comic Sans”;

    font-size: 12pt

    color: red;

    text-align: center

    }

    Now, every time we use any of the headers, the text will automatically have the font type of Comic Sans, have a font size of 12 points, be red in color, and aligned to the center of the page.

    Assigning the Same HTML Element with a Different Value

    Say you wanted to have an <h1> header tag with a certain default value. Every time you used that tag, it would have the attributes you defined. But what if every once in a while you wanted to insert an <h1> tag that had different attributes? Well you can do so by using the Class Selector. Here it is in code:


    h1.weird {font-family:”Comic Sans”;color:red}

    h1.notweird{font-family:Verdana;color:black}


    The above would create two Class Selectors. If you typed h1.weird, it would apply the attributes you defined in that Selector. If you typed h1.notweird, it would apply the font as Verdana and the color as black.

    This allows you more flexibility when designing your site.

    You use the class attribute to apply it:


    <h1 class=”weird”>

    Here is a mighty header!

    </h1>

    <h1 class=”notweird”>

    Here is an even mightier header!

    </h1>

    Say I wanted to add more than one class to my element. First, let's create a third element:


    h1.weird {font-family:”Comic Sans”;color:red}

    h1.notweird{font-family:Verdana;color:black}

    h1.center{text-align:center}

    Now to apply two of the classes:


    <h1 class=”weird center”>

    Here is a mighty header!

    </h1>

    More Style Sheets Articles
    More By James Payne


       · Thanks for dropping by to read my article on CSS. In this tutorial we talk about...
     

    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 1 hosted by Hostway