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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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

    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...
    - Pulling Web Page Elements with the Blueprint...
    - Pushing Web Page Columns with the Blueprint ...
    - Controlling Column Padding with the Blueprin...
    - Prepending Classes in the Blueprint CSS Fram...
    - Appending Grid Units with the Blueprint CSS ...
    - Changing Grid Units in the Blueprint CSS Fra...
    - The Blueprint CSS Framework
    - Building a Liquid Design with Evened Margins...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT