You are here: Reference > JavaScript > client-side > HTML DOM > properties > aLink (body)

aLink property (body)

Browser support:
Sets or retrieves the color of the active hypertext links in the entire document.
This property is deprecated.
Use the active pseudo with the color style property to modify the color of an active link: 'a:active {color:#00FFFF;}'. See Example 2 for details.
The aLink property is equivalent to the aLink property.

Syntax:

object.aLink;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: aLink

Possible values:

A legal color value. It can be a hexadecimal, RGB or predefined color value. For more information, see the page for colors.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the aLink, link and vLink attributes:
<body aLink="green" link="red" vLink="black">
    Click on the following hyperlinks to see the default, normal and visited states:
    <br /><br />
    <a href="#first">Hyperlink text</a>
    <br /><br />
    <a href="#second">Hyperlink text</a>
    <br /><br />
    <a href="#third">Hyperlink text</a>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the color style property for hypertext links:
<head>
    <style>
        a:link { color: red; }
        a:visited { color: black; }
        a:active { color: green; }
    </style>
</head>
<body>
    Click on the following hyperlinks to see the default, normal and visited states:
    <br /><br />
    <a href="#first">Hyperlink text</a>
    <br /><br />
    <a href="#second">Hyperlink text</a>
    <br /><br />
    <a href="#third">Hyperlink text</a>
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the aLink, link and vLink properties, but we recommend to set the link colors from CSS as shown in Example 4:
<head>
    <script type="text/javascript">
        function ChangeLinkColors () {
            document.body.aLink = "red";
            document.body.link = "blue";
            document.body.vLink = "green";
        }
    </script>
</head>
<body aLink="green" link="red" vLink="black">
    Click on the following hyperlinks to see the default, normal and visited states:
    <br /><br />
    <a href="#first">Hyperlink text</a>
    <br /><br />
    <a href="#second">Hyperlink text</a>
    <br /><br />
    <a href="#third">Hyperlink text</a>

    <br /><br /><br />
    <button onclick="ChangeLinkColors ();">Change the colors of hypertexts</button>
</body>
Did you find this example helpful? yes no

Example HTML code 4:

Recommendation to change color style properties for hypertext links:
<head>
    <style>
        a:link { color: red; }
        a:visited { color: black; }
        a:active { color: green; }
    </style>
    <script type="text/javascript">
        function ChangeLinkColors () {
            var sheet = document.styleSheets[0];
            var rules = sheet.cssRules ? sheet.cssRules : sheet.rules;
            rules[0].style.color = "blue";
            rules[1].style.color = "green";
            rules[2].style.color = "red";
        }
    </script>
</head>
<body>
    Click on the following hyperlinks to see the default, normal and visited states:
    <br /><br />
    <a href="#first">Hyperlink text</a>
    <br /><br />
    <a href="#second">Hyperlink text</a>
    <br /><br />
    <a href="#third">Hyperlink text</a>

    <br /><br /><br />
    <button onclick="ChangeLinkColors ();">Change the colors of hypertexts</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content