| You are here: | About>Computing & Technology>Web Design / HTML> CSS> CSS2> CSS2 Generated Content - Content Stored in Style Sheets |
![]() | Web Design / HTML |
More Help with Advanced CSSHTML References / Web Design ReferencesCSS 1 and CSS 2 PropertiesHTML 4.01 Tags / XHTML 1.0 ElementsHTML Codes CSS 2 Generated Content:before and :after Pseudo-ElementsCascading Style Sheets level 2 (CSS2) provides Web developers with a convenient way to generate content for their Web pages without having that content stored in the document tree. This is intended for:
Note: Before you start playing with these classes, you should be aware that they are not supported by Internet Explorer. :before and :after Pseudo-ElementsThese pseudo-elements work on other elements in the style sheet to determine the location of any generated content. As you might guess :before places the content before the element and :after places it after. p:before { content: "Note:"; } With these pseudo-elements, the non-inherited properties take their initial or default values. The most common use of this is with display. Display has the default value of in-line, but for a lot of generated content, you want it to be a block element. For example, if you wanted to put a graphical element between sections on a page, you might write: div.section:after { Generating ContentOnce you have the :before and :after pseudo-elements, you need to determine what content you're going to generate. The three most common types of content you might generate are:
To include a string, just include the text you want generated in quotes: p:after { content: "The End"; } If you want to include quotes in your content, escape them with the back-slash: \". To include an image, use the call url(URI to image): p:before { content: url(../graphics/ball.gif); } Finally, to include quotation marks you use the terms open-quote and close-quote: q:before { content: open-quote; } More Help with Advanced CSSHTML References / Web Design ReferencesCSS 1 and CSS 2 PropertiesHTML 4.01 Tags / XHTML 1.0 ElementsHTML Codes |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


