Two columns Three columns Mixed cols and rows Gallery Archives Clean & Clear Dark or Black High Contrast/ Impact Blog Designs New Corporate/ Professional Unconventional Designs Liquid layouts Web Design Firms Our Favorites What's Popular Last 20 submissions
Horizontal Menus Vertical Menus Multiple/ Nested Levels

CSS Examples Generated Content in CSS2

Date: 11/01/2004 Generated Content in CSS2

Author: CSS Drive

CSS2 supports the insertion of generated content, which is content that's specified using your style sheet and applied dynamically to the page according to your CSS definition. This is accomplished using the ":before" and ":after" pseudo-classes, which denotes whether the content should be added before or after the element in question. You can insert regular "string" content or an embedded object (ie: an image). CSS2's Generated Content is supported in Mozilla/Firefox and Opera 7, though not IE 6.

The word "Chapter:" in each of the headers below are dynamically generated using CSS2:

1

2

3

The music icon image next to the midi links are dynamically added as well:

CSS Drive
Music1.mid
Music2.mid

The CSS:

h2:before{
content: "Chapter: ";
}

a.music:after{
content: url(icon.gif);
}

The HTML:

<p><b>The word "Chapter:" in each of the headers below are dynamically generated using CSS2:</b></p>

<h2>1</h2>
<h2>2</h2>
<h2>3</h2>

<p><b>The music icon image next to the midi links are dynamically added as well:</b></p>

<a href="http://www.cssdrive.com">CSS Drive</a><br />
<a href="music1.mid" class="music">Music1.mid</a><br />
<a href="music2.mid" class="music">Music2.mid</a><br />

Comments (23)

What's with the IE incompatibility ? I think this should work with all "state of the art browsers"

#1: lage lonen landen on 12/05 at 05:16 PM

Why doesn't this work for me? What am I doing wrong? ontwikkeling

#2: Mary-Anne Davis on 12/20 at 06:49 PM

hey it's not working with IE7 !? what can i do ? seo in iasi

#3: Smith on 12/27 at 02:53 PM

Post a Comment: Guest (Login or Register)

Name: (Required)

Email: (Required)

(NOT shown on page)

URL:

(Shown on page if entered)

Comments: (Required)

Remember my personal information
Notify me of follow-up comments?

Submit the word you see below:


CSS Forums

CSS Forums: latest threads Last Post Info
How to show an entire pdf in one div (2) 05/14/2008 11:07 am
By: Grundic
Starting A Web Design Business - How Do I Attract Customers? (10) 05/13/2008 02:37 pm
By: april
Download.. Pacific Wings multicolor menu (1) 05/13/2008 03:05 am
By: sebreh
Check out this website I am working on CRITIQUE. (5) 05/13/2008 01:20 am
By: abran
Tables or Div's? What's you opinion? (18) 05/12/2008 05:18 pm
By: wilwaldon