Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:

Advertise Here

CSS Library: Other: Here

CSS Generated Content

Author: Dynamic 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 very useful for further decorating an element with rich content that should not be part of the page's actual markup. CSS Generated Content 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+, and IE7+

In our first example, we'll automatically add the decorative text ":: " in front of all H3 headers using CSS generated content, and make it red as well:

Dynamic Drive CSS Library

If you're using a capable browser, you should see the effect.

In the next example, you'll see how to include an image as part of the generated content:

whatever.zip

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 05/02/2006

Revision History: None

Usage Terms: Click here

Your Comments (34)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Comment Pages 4 of 4 pages « First  <  2 3 4

This work on IE and Firefox

.zipfile{
background:transparent url(media/zip.gif) left center no-repeat;
padding-left:20px;
}
Posted by Rodrigo on 11/13, 07:51 AM
I have IE7 and I don't see anything. I had to open the page using Firefox to see the image.

I guess it's a dumb question to ask if search engines can read CSS generated content, but I'll ask anyway...

Can search engines read CSS generated content?
Posted by Bill on 12/03, 06:47 PM
Thanks for sharing the nice article. i am looking for the imitation earrings.
Posted by imitation jewellery india on 05/28, 05:34 AM
Thanks for sharing the nice article.
Posted by Think Flick on 06/02, 11:38 PM

Comment Pages 4 of 4 pages « First  <  2 3 4


Commenting is not available in this weblog entry.
Copyright 2006-2011 Dynamic Drive Read our Usage Terms before using any of the CSS codes.