154 CHAPTER 4 Getting started with CSS3
<a href='http://microsoft.com' >Link 3</a><br />
</body>
</html>
The first and third <a> elements define the href attribute, which means that hovering over
either of these causes the hyperlink to be displayed. The result is shown in Figure 4-3.
FIGURE 4-3 Hovering over a link whose href attribute is defined, causing the href value to be displayed
Using an attribute value selector
An attribute value selector selects all elements where the specified attribute has the specified
value. For example, a[href=’http://contoso.com’] selects all hyperlinks where the href attribute
is set to http://contoso.com.
The following example demonstrates the use of the attribute value selector to locate all
hyperlinks that have the href attribute set to http://contoso.com. This example also demon-
strates combining the attribute selector with the :hover pseudo class.
a[href='http://contoso.com']:hover {
background-color: yellow;
}
Consider the following HTML document, which has three <a> elements, one of which has
the href attribute set to http://contoso.com.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="default.css" rel="stylesheet" />
</head>