SunQuest
 
       Style Sheets
  Home arrow Style Sheets arrow Learn CSS, part 7: Pseudo Elements
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 
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 7: Pseudo Elements
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2005-06-27

    Table of Contents:
  • Learn CSS, part 7: Pseudo Elements
  • Using the ::first-line Pseudo Element
  • Using the ::first-letter Pseudo Element
  • Using the ::selection Pseudo Element
  • The Content Property
  • The ::before and ::after Pseudo Elements

  • 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
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry 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 7: Pseudo Elements


    (Page 1 of 6 )

    We have discussed CSS selectors in the last three articles in this sereis. We have said that a selector can be a markup element, an attribute selector based on the class and ID attributes, or a structured selector based on the document structure. CSS introduces pseudo elements, which we will be discussing in this article. This is one area of functionality that you can't achieve using HTML, and you will be amazed how easily you can achieve it in CSS.

    As you know, a selector like h1 refers to all the <h1> elements in the markup document. You can directly apply any formatting styles to the <h1> elements with no problems. Sometimes, however, we need to apply certain formatting rules on parts of the document that can't be represented using HTML.

    For example, maybe you need to apply a blue background and a text color of yellow to the first letter of a paragraph or a <Div> element, or maybe you want to change the font-size of the first line of each paragraph in your HTML file. There are no elements in the HTML that can do such things. In other words, there's neither a <firstletter> element nor a <firstline> element in HTML.

    CSS gives us the ability to apply styling rules to certain parts of the document by using pseudo elements. Pseudo elements refer to parts of the document that you cannot directly access through the HTML-- but the browser can, through the Web designer PSEUDO. In other words, you don't have access to the first line of a paragraph using HTML elements, but CSS has a pseudo element to give you access to it and to let you apply your styling rules to it through the browser.

    It's the browser's responsibility to get to these elements. We call them pseudo elements because they don't exist in the markup and we don't have direct control over them, as you will see in the code examples in this article. Let's begin.

    More Style Sheets Articles
    More By Michael Youssef


       · Hi, I was trying to keep up but do better with a full working example. Thank You
       · Thanks for your comment but I thought that all the readers can create a style sheet...
     

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