HTML and CSS Reference
In-Depth Information
he colors that a browser uses to indicate the normal, active, and visited
states to the user can be set with
link
,
alink
, and
vlink
attributes of the
body
element, as shown next. hese attributes were introduced before there was sup-
port for CSS. CSS is the preferred way of styling hyperlinks.
<body link="darkblue" alink="red" vlink="grey">
In CSS, the state of an
anchor
element can be selected for rule assignment
using the pseudo-selectors:
link
,
hover
,
active
, and
visited
. he following CSS
rules set the same values as the attributes in the preceding
body
tag and change
the background color when the user's mouse hovers over an anchor element.
Other CSS statements in the document's styles can set diferent values for spe-
ciic elements and classes of elements.
<style type="text/css">
a { color: blue; }
a:active { color: red; }
a:visited { color: green; }
a:hover { background-color: yellow; }
</style>
hese states are also available to client-side scripts as document object
properties. Changes in the state of an anchor can be detected using event
handler attributes such as
onmouseover
,
onmouseout
,
onfocus
,
onblur
,
onclick
,
onmousedown
, and
onmouseup.
In addition to the
href
and
name
attributes, anchor and
area
elements can have
the
target
and
title
attributes. he
target
attribute provides a means for Web
authors to have links open in a new window. he
target
attribute provides the
name of the browser window in which to open the requested document. If no
existing window has that name, a new window is created with that name. he
special target name
"_blank"
always opens a new window with no name.
A window's name is an internal name that can be used by scripts in one
document to play with the elements of another document loaded into a dif-
ferent window. It is not the same as the window title, which is set by the
title
attribute in the document's
head
section. he
title
attribute can set the win-
dow title in cases where the requested document is not an HTML resource and
does not have a title element of its own, such as with a JPEG image or text ile.
For example: