The Wayback Machine - https://web.archive.org/web/20090220045319/http://www.webreference.com:80/html/tutorial6/7.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Pseudo-elements

Developer News
Windows Mobile 6.5 Debuts But Is It Too Late?
A Better Grip on Open Source Projects?
Red Hat, Microsoft in New Interoperability Pact

Just like pseudo-classes are used to select elements that have special properties that cannot be expressed with other kinds of selectors, the concept of pseudo-elements was created to apply style rules to portions of a document that cannot be otherwise selected.

Pseudo-elements are specified in selectors exactly as pseudoclasses are: by using a colon (:). The two types of pseudo-elements defined by CSS1 are first-letter and first-line. The first-letter pseudo-element selects a theoretical element that contains only the first letter of an element. The first-line pseudo-element selects a theoretical element that contains only the first line of an element.

Unfortunately, neither of these pseudo-elements are supported by current browsers. If they where, they could be used to create interesting effects such as drop capitals. The following example gives two rulesets and a P element to which they apply. The rendering of this element is actually a picture of what it should look like if a browser supporting typographical pseudo-elements displayed this paragraph. The first line of the element is made bold, and the first letter is made three times larger and floats to the left (I will explain these properties, like all the others I have used so far, in future tutorials).

P:first-line {
  font-weight: bold;
}
P:first-letter {
  font-size: 300%;
  float: left;
}
<P>This is a rather long paragraph that should 
wrap into more than one line if the viewing window 
is sufficiently narrow and the text is sufficiently 
long, which should be the case with most setups.
image of a pararaph of text with a drop-cap effect and a bold first line

That's all for this time, folks. This tutorial has covered the selector syntax described in CSS level 1. CSS2 defines some more advanced forms of selectors, but since these are currently unsupported by browsers, and are pretty specialised anyway, so we'll look at those later on. In tutorial 7, we'll take a peek at how a browser should combine style rules from embedded style sheets, linked style sheets, and STYLE attributes to decide which should apply to an element, and understand why Cascading Style Sheets, well, cascade...

Front Page1234567

http://www.internet.com

Produced by Stephanos Piperoglou

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Creating Custom Error Pages on Apache Servers · Django for the Impatient: Blog Building Basics · Introducing the ASP.NET Ajax Frameworks
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/html/tutorial6/7.html
Created: September 24, 1998
Revised: September 24, 1998

Morty Proxy This is a proxified and sanitized view of the page, visit original site.