Style Sheets
  Home arrow Style Sheets arrow Page 5 - Learn CSS, part 1
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 
VeriSign Whitepapers 
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, part 1
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 30
    2005-05-16

    Table of Contents:
  • Learn CSS, part 1
  • CSS Specifications and Implementations
  • Browsers we are going to use
  • The HTML vs. CSS example
  • CSS rules and selectors
  • Groups of Selectors
  • Validating your CSS Documents

  • 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

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Learn CSS, part 1 - CSS rules and selectors


    (Page 5 of 7 )

    As we said before, CSS is a styling language for Web pages. This means that CSS styles mark up elements such as <p>, <h1>, <a> and pretty much all the other elements. In CSS we call the element that we want to style a selector, like the paragraph selector from the above example.

    p
    {
    font-family: Arial, sans-serif;
    color: red;
    }

    We select each and every <p> element in the HTML page to have an Arial font with a red color. The term selector makes sense because you select which part of the page (which element or which elements as we will see shortly) will receive the application of specific styles. So the selector p refers to the HTML element <p>, and so on. You define the actual styling using CSS properties, such as the font-family and color properties. There are many properties in CSS, and we are going to take a look at most (if not all) of them. To set a value to a given property, you write the property followed by a colon, then the value, which must be followed by a semicolon, as shown with the font-family property below:

    font-family: Arial, sans-serif;

    This combination of property, colon, value and semicolon is called a CSS declaration. The combination of the selector (the p) and the declaration is called a CSS rule, which begins with a selector (or a group of selectors as we will discuss shortly), then an opening curly brace "{" followed by as many CSS declarations as you want, followed by a closing curly brace "}". CSS documents consist of CSS rules, which define what styling properties go with what selectors. We will discuss selectors in detail after a few articles in this series, but for now you need to understand that selectors are not just <p>, <a>, <body> and other HTML elements. You can define your own selectors and apply them using the id or class attributes.

    More Style Sheets Articles
    More By Michael Youssef


       · Pretty basic stuff; certainly not bad, though.You can find another (slightly...
       · Hello, I have wrote 10 articles in my Learn CSS Series and most of them have...
       · I have written the following articles in the CSS series in the following order1-...
       · As strictly a web designer (not coder!) that relied on Dreamweaver/HTML for small...
       · W3 is strictly show-and-tell. It doesn't explain the concepts presented. Units of...
     

    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


    Iron Speed





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