HTML link Attribute
The obsolete HTML link attribute was historically used on the <body> element to specify the color of unvisited hyperlinks throughout a document.
link attribute is obsolete and should not be used in modern HTML. Use the CSS :link pseudo-class and the color property to style unvisited links.
Historical Syntax
The link attribute was placed on the <body> element and given a color value:
<body link="blue">
<a href="page.html">Example Link</a>
</body>
In this example, unvisited hyperlinks in the document were displayed in blue.
Historical Elements
The obsolete link attribute was associated with the <body> element.
| Element | Historical Purpose |
|---|---|
<body> |
Specified the color used for unvisited hyperlinks throughout the document. |
Historical Use
The link attribute gave authors a simple way to change the default color of unvisited links for an entire webpage. Instead of styling individual <a> elements, the color was specified once on the <body> element.
The attribute was commonly used with vlink and alink. The link attribute controlled unvisited links, vlink controlled visited links, and alink controlled links while they were being activated.
<body link="blue" vlink="purple" alink="red">
...
</body>
These attributes provided only basic color control. They could not provide the broader range of link styling available through CSS.
Why It Became Obsolete
The link attribute controlled presentation rather than the structure or meaning of the document. CSS became the standard method for controlling link colors and other visual styles.
CSS can style different link states independently and can control properties such as color, text decoration, background, borders, and other visual effects. Styles can also be reused throughout a website instead of being placed directly in the HTML.
Modern Alternative
Use the CSS :link pseudo-class with the color property instead of the obsolete link attribute.
Historical HTML
<body link="blue">
<a href="page.html">Example Link</a>
</body>
Modern HTML and CSS
<a href="page.html">Example Link</a>
<style>
a:link {
color: blue;
}
</style>
The :link pseudo-class selects links that have not been visited. CSS can also style the other common link states:
a:link {
color: blue;
}
a:visited {
color: purple;
}
a:hover {
color: green;
}
a:active {
color: red;
}
When styling these link states together, a common order is :link, :visited, :hover, and :active. This helps prevent later rules from unexpectedly overriding styles for interactive link states.
Links should also remain visually distinguishable from surrounding text. Color can be part of the design, but removing other visual cues such as underlining can make links harder for some users to identify.
Play in EditorLearn More About Styling Links
The CSS tutorials explain how to style hyperlinks and use pseudo-classes to respond to different link states:
- CSS Styling Links - Learn how to control the appearance of hyperlinks and their different states.
- CSS Pseudo-classes - Learn how pseudo-classes such as
:link,:visited,:hover, and:activeselect elements in particular states. - CSS Text Color - Learn how the CSS
colorproperty controls text color.
Legacy Browser Support
The link attribute was widely supported by older browsers because it was part of early HTML presentation features for controlling document link colors.
Modern browsers may continue to recognize the attribute when displaying older webpages, but new and updated webpages should use CSS pseudo-classes and the color property instead.
For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.
Related Attributes
Other obsolete HTML attributes historically used to control link colors include:
Specifications
The link attribute on the <body> element is obsolete and link colors should be controlled with CSS. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.
