30 Aug
Posted by ProCOM
on August 30, 2007 – 2:43 pm - 328 views
If you're new here, you may want to subscribe to my RSS feed. So that you can read the latest updates about Web2.0 tools, Making Money Online, Tips in SEO, Ajax and many more. Thanks for visiting ProgramimiCOM!
Pseudo-classes and pseudo-elements are special “classes” and “elements” that are automatically recognized by CSS-supporting browsers. Pseudo-classes distinguish among different element types (e.g., visited links and active links represent two types of anchors). Pseudo-elements refer to sub-parts of elements, such as the first letter of a paragraph.
Rules with pseudo-classes or pseudo-elements take the form
selector:pseudo-class { property: value }
or
selector:pseudo-element { property: value }
Pseudo-classes and pseudo-elements should not be specified with HTML’s CLASS attribute. Normal classes may be used with pseudo-classes and pseudo-elements as follows:
selector.class:pseudo-class { property: value }
or
selector.class:pseudo-element { property: value }
Pseudo-classes can be assigned to the A element to display links, visited links and active links differently. The anchor element can give the pseudo-classes link, visited, or active. A visited link could be defined to render in a different color and even a different font size and style.
An interesting effect could be to have a currently selected (or “active”) link display in a slightly larger font size with a different color. Then, when the page is re-selected the visited link could display in a smaller font size with a different color. The sample style sheet might look like this:
A:link { color: red }
A:active { color: blue; font-size: 125% }
A:visited { color: green; font-size: 85% }
Often in newspaper articles, such as those in the Wall Street Journal, the first line of text in an article is displayed in bold lettering and all capitals. CSS1 has included this capability as a pseudo-element. A first-line pseudo-element may be used in any block-level element (such as P, H1, etc.). An example of a first-line pseudo-element would be:
P:first-line {
font-variant: small-caps;
font-weight: bold }
The first-letter pseudo-element is used to create drop caps and other effects. The first letter of text within an assigned selector will be rendered according to the value assigned. A first-letter pseudo-element may be used in any block-level element. For example:
P:first-letter { font-size: 300%; float: left }
would create a drop cap three times the normal font size.
Print This Post
Email This Post
Comments RSS
TrackBack Identifier URI
You must be logged in to post a comment.