pseudo element selectorsExplanationSince its inception as an ASCII text only medium for the sharing of scientific papers (no style, no images, no page layout), the web has become a new medium of expression and publication. It still takes its cue from the printed page, being primarily a static medium for the expression of the type of information that traditionally has been published on paper. Two traditional typographical effects which the developers of CSS1 felt it important to easily enable in web pages are provided for by pseudo element selectors. Very often in traditional publishing the first letter and the first line of a paragraph appear differently from the rest of that paragraph. The The CSS2 introduced two new pseudo-element selectors, The Why are these called pseudo element selectors? Think about this: is there an HTML element for the first letter of an element? What about the first line? No. So, when we "select" the first line, we are really inventing something to select, which isn't in the HTML. That's why we refer to these as pseudo elements. SyntaxThe For example, the selector which selects the first line of every blockquote is: blockquote:first-line and that which selects the first-line of each paragraph is: p:first-line The blockquote:first-letter while the first letter of a paragraph is selected with this selector: p:first-letter The before and after selectors are the same, but substituting the keyword So for example if you wanted to insert some generated content before every heading of level 1 you would use: h1:before And if you wanted to insert some generated content after every code sample on your page, you would use: code:after UseThe The Remember, the idea behind style sheets is to separate out the appearance of your pages from the content. Without this selector, it would be necessary to physically mark up the first line or first letter of a paragraph or other element to achieve these effects. The You might like to think about this example. It might be convenient to insert the text string "Chapter " before all your headings of level 1. Browser supportDetailed browser support information for this feature can be found in the full version of the Westciv CSS Guide, or in our CSS Browser Support Table. next: selector groups(C)1997-2001 Western Civilisation Pty. Ltd. |