Style Sheets
  Home arrow Style Sheets arrow Page 4 - CSS for the Newbie
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

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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    CSS for the Newbie - Applying a Style to an Element with an Attribute


    (Page 4 of 5 )

    If you want to apply your style to elements with certain attributes, you can do so in the following manner:


    input[type=”textarea”] {background-color: yellow}

    This will give every textarea in your page a background color of yellow.

    Using the id Selector

    The Id Selector allows you to apply styles to HTML elements that have a specific id value. Here is an example:


    #fred {text-family: Verdana; color: orange}

    The above code will apply the style to any HTML element with an ID value of “fred,” whether it's a table, a paragraph, a header, etc.

    If we wanted to apply the style to a specific element type with an ID value, we would do so like this:


    h1#bigguns

    {

    text-family:Impact;

    color: purple

    }

    This rule would be applied to an H1 tag that had the id of “bigguns.”

    Just a reminder regarding the ID of elements: you may not have two elements with the same id value in the same document, and value must begin with a letter from the alphabet. The value is case-sensitive and may contain letters, numbers, hyphens, underscores, colons, and periods.

    Leaving a Comment

    Everyone likes to put their two cents in, and even nerdy programmers are no exception. In fact, they probably comment more than anyone else. Leaving comments in your code is a good way to tell future programmers, who may have to work on your code, what exactly it was you were trying to accomplish. It is also a useful reminder for yourself when you look back upon it months later and wonder what the heck you were doing.

    In CSS you leave comments like so:


    /* Look at me I am a comment! The browser does not see me tee-hee! */

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