Style Sheets
  Home arrow Style Sheets arrow Page 5 - What is CSS?
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

What is CSS?
By: Marc Knuttel
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2004-05-17

    Table of Contents:
  • What is CSS?
  • CSS Syntax
  • Placement of CSS Elements
  • Cascading - What Does it Mean?
  • Your First Style Sheet

  • 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


    What is CSS? - Your First Style Sheet


    (Page 5 of 5 )

    As HTML becomes more and more a description of the content of Web pages and less the look and feel, you need a tool to describe how your pages should look. That's where Cascading Style Sheets (CSS) come in.

    CSS is not hard, in some ways it's almost easier than HTML. The trickiest part is remembering the many different choices you have to choose from. Let's start with a simple style sheet that includes some of the more common styles.

    Fonts

    The most common adjustment to Web pages is to the fonts on the page. You can change the color, style, size, and face of your fonts, and you can do it all with CSS.
     
    Creating a Style Sheet

    The first key to writing a style sheet is to decide what you want your text to look like. You should decide the color, the font, the style and so on. You also need to decide what the different styles should be for the different tags, headings, and so on.

    My Proposed Styles

    • Standard paragraph text should be black, arial narrow, and medium sized
    • Top level (h1) headings should be red, bold, and small-caps
    • Second level headings (h2) should be blue and italic
    • Notations should be standard text with a yellow background

    These are the CSS elements that can change the font:

    • font-family - Change the actual face of the font. You can use specific font names or generic terms such as serif, sans-serif, monospace, courier, fantasy.

      font-family : arial, geneva, helvetica;


    • font-size - Change the size of the font. Define the size as an absolute size, relative size, percentage, or length.

      font-size : small


    • font-style - Changes the style from normal to italics or oblique.

      font-style : italic


    • font-variant - Change the look of the text from normal to small-caps.

      font-variant : small-caps


    • font-weight - Change the font to bold.

      font-weight : bold


    • color - Change the color of your text. Use either named colors or hexadecimal codes.

      color : #ff0000


    • background-color - Change the color behind the text. Use either named colors or hexadecimal codes.

      background-color : yellow;

    Once you've decided on the styles you want, you need to write your style sheet. Place the following in the <head> of your HTML document:

    <style type="text/css">
    <!--
    p { color : #000000; font-family : arial narrow; font-size : medium; }
    h1 { color : #ff0000; font-weight : bold; font-variant : small-caps; }
    h2 { color : #0000ff; font-style : italic; }
    .note { background-color : #ffff00; }
    -->
    </style>

    The first three of the above styles will be set by using the tags: <p></p>, <h1></h1>, and <h2><h2>. The final style notation is used with the class attribute. Since it is a notation, it would usually be used with the <span></span> tag. For example:

    <p>
    This paragraph would be in the p style. <span class="note">Note: inheritance means that this text will have the same styles as the paragraph itself</span>
    </p>

    The styles set by the first tag will be inherited by any tag that is within it. This is why we don't have to redefine the font color or size for the note.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - 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...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek