SunQuest
 
       Style Sheets
  Home arrow Style Sheets arrow CSS: Pseudo
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

CSS: Pseudo
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2008-05-19

    Table of Contents:
  • CSS: Pseudo
  • Dealing with the :first Line Pseudo Element
  • Pseudo Classes
  • A Preview of Mouse-over Effects

  • 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: Pseudo


    (Page 1 of 4 )

    We left off learning about the various positions in CSS. In this tutorial we will cover the pseudo classes and pseudo elements, which allow us to add special effects to our selectors. An example would be roll-over effects on hyperlinks, or making the first letter of a sentence larger and a different color than the rest of the text.

    We will begin our discussion by working with Pseudo-elements.

    Dealing with the :first Letter Pseudo Element

    The :first letter Pseudo Element allows us to change the first letter of our selector by adding a special effect to it. Below is an example of how to make the first letter larger than the rest of the text:


    <html>

    <head>

    <style type="text/css">

    p:first-letter

    {

    font-size:xx-large

    }

    </style>

    </head>

    <body>

    <p>

    Once upon a time in a land, right down the street, there lived this fat ugly dude that owed me a lot of money. So I sent the politically stupid yet Kung-Fu intelligent Chuck Norris to his house to collect.

    </p>

    </body>

    </html>

    Go ahead and try it out. Isn't that a beautiful fairy tale? As you can see, the "O" in "Once" becomes huge. Now let's add some other effects to it. Since this wondrous fairy tale is all about whippin' that butt, let's make the "O" red, like blood:


    <html>

    <head>

    <style type="text/css">

    p:first-letter

    {

    color: red;

    font-size:xx-large

    }

    </style>

    </head>

    <body>

    <p>

    Once upon a time in a land, right down the street, there lived this fat ugly dude that owed me a lot of money. So I sent the politically stupid yet Kung-Fu intelligent Chuck Norris to his house to collect.

    </p>

    </body>

    </html>

    And finally, we will add some more effects to our first letter to make it look even more spiffy:


    <html>

    <head>

    <style type="text/css">

    p:first-letter

    {

    color: red;

    font-size:xx-large;

    text-decoration: overline underline;

    }

    </style>

    </head>

    <body>

    <p>

    Once upon a time in a land, right down the street, there lived this fat ugly dude that owed me a lot of money. So I sent the politically stupid yet Kung-Fu intelligent Chuck Norris to his house to collect.

    </p>

    </body>

    </html>

    You can add all of the following to :first letter: 

    • font properties

    • color properties

    • background properties

    • margin properties

    • padding properties

    • border properties

    • text-decoration

    • vertical-align (only if 'float' is 'none')

    • text-transform

    • line-height

    • float

    • clear

    You can also mix your classes with your pseudo elements, allowing you to add effects to all of your elements of the same class easily. Behold!

    <html>

    <head>

    <style type="text/css">

    div.cool:first-letter

    {

    color: red;

    font-size:xx-large;

    text-decoration: overline underline;

    }

    </style>

    </head>

    <body>

    <div class="cool">

    Once upon a time in a land, right down the street, there lived this fat ugly dude that owed me a lot of money. So I sent the politically stupid yet Kung-Fu intelligent Chuck Norris to his house to collect.

    </div>

    <br>

    <div class="cool">Needless to say, there was much bloodshed.</div>

    </body>

    </html>

    More Style Sheets Articles
    More By James Payne


       · would have liked to comment, but keep it to myself now, as i dont like the attribute...
     

    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