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


    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

    - 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...
    - An Evened Margin Approach to Centering DIVs ...
    - Using Auto Margins with Multiple Columns to ...
    - Using Auto Margins with a Liquid Layout to C...
    - Using Auto Margins to Center DIVs with CSS
    - Using the Text-align CSS Property to Center ...







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