HTML and CSS Reference
In-Depth Information
Pseudoclasses
Pseudoclasses, which use colons to separate an element from its state, are more sophisticated selectors. They are
frequently used to determine the style of hyperlinks, depending on their states. For example, Listing 5-33 applies to all
a elements but only when the mouse hovers over the link.
Listing 5-33. Link Color to Be Applied in Case an Anchor Is Being Hovered Over
a:hover {
color: #000080;
}
Another example is Listing 5-34, which changes the color of all hyperlinks that have already been visited 5 to green.
Listing 5-34. Link Color Set to Visited Hyperlinks
a:visited {
color: #0f0;
}
Pseudoelements
Pseudoelements can be used to add style to specific element parts instead of whole elements. They can also be applied
for inserting content before or after certain elements. The combinator is a colon ( : ). For example, the CSS rule in
Listing 5-35 changes the font size of the first letter of all paragraphs within the web page to 2 em.
Listing 5-35. A Rule for the First Letter of Paragraphs
p:first-letter {
font-size: 2em;
}
Property Value Types
CSS property values can be the following:
auto )
Keywords (for example,
% )
Basic data types (for example,
url
( ' http://www.masteringhtml5css3.com/img/webstandardsbook.jpg ' )
Combination of keyword and custom data (for example,
Shorthand Notation
Certain CSS properties can be grouped into a single property declaration. The most common shorthand notations are
described in the following sections.
5 According to the current browser history.
 
Search WWH ::




Custom Search