JavaScript Document alinkColor Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

document.alinkColor gets or sets the color of an active link in the document body — the brief state between mousedown and mouseup on a link (MDN).

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.alinkColor. Start with this line.

JavaScript
document.alinkColor
CallWhat it does
document.alinkColorPrimary signature.

Built into the browser. Read or assign document.alinkColor — no import required.

Library declarations
JavaScript
document.alinkColor

Parameters

ParameterDescription
Writable?Required. Getter and setter

Return Value

Return ValueDescription
*The current value of document.alinkColor.

JavaScript Examples

Example 1 — Read alinkColor

Log the current active-link color string.

JavaScript
console.log(document.alinkColor);
console.log(typeof document.alinkColor);
Try It Yourself

How It Works

  1. Read the property. Returns a string color (name or hex).
  2. Check typeof. Always a string in supporting browsers.
  3. Defaults differ. Firefox’s default is red #ee0000 (MDN).
  4. Deprecated. Prefer reading styles via CSS / computed style in new work.

Example 2 — Set alinkColor (Legacy)

Assign a color name or hex. Useful only for understanding old pages.

JavaScript
document.alinkColor = "orange";
console.log(document.alinkColor);

document.alinkColor = null;
console.log(document.alinkColor); // ""
Try It Yourself

How It Works

  1. Assign a string. Names or hex values are accepted (MDN).
  2. Re-read. Confirms the stored value (browser may normalize the string).
  3. Assign null. MDN: converted to "".
  4. Do not ship this. Use CSS for production styling.

Example 3 — Prefer CSS :active

Modern replacement recommended by MDN.

JavaScript
const style = document.createElement("style");
style.textContent = "a:active { color: #ff6600; }";
document.head.append(style);

console.log("using CSS :active instead of alinkColor");
Try It Yourself

How It Works

  1. Create a stylesheet rule. Targets links in the :active state.
  2. Append it. The browser applies it without Document color properties.
  3. Same UX goal. Pressed-link color, without deprecated APIs.
  4. Prefer static CSS in real projects (a <style> or stylesheet file).

Browser Support

Document.alinkColor is a legacy Document color property. MDN marks it Deprecated. It may still work for compatibility, but CSS :active is the supported approach.

✓ Deprecated

Document.alinkColor

Still readable in many browsers for old pages. Do not rely on it for new UI — use CSS link pseudo-classes.

Legacy Deprecated API
Google Chrome Legacy support
Yes
Microsoft Edge Legacy support
Yes
Mozilla Firefox Legacy · default #ee0000
Yes
Apple Safari Legacy support
Yes
Opera Legacy support
Yes
Internet Explorer Legacy support
Yes
alinkColor Prefer CSS :active

Bottom line: Learn it for migration only. See the MDN Document.alinkColor reference and use CSS :active instead.

Frequently Asked Questions

It gets or sets the color of an active link in the document body. A link is active between mousedown and mouseup — while the user is pressing the mouse button on it (MDN).
Yes. MDN marks Document.alinkColor as Deprecated. Prefer CSS :active (and related link pseudo-classes) in new code.
A string color name (such as blue or darkorange) or a hexadecimal color (such as #0066CC). Setting null is converted to the empty string.
MDN notes the default alinkColor in Mozilla Firefox is red (#ee0000 in hexadecimal).
Legacy Document properties include linkColor (unvisited), vlinkColor (visited), and alinkColor (active/pressed). Modern CSS uses :link, :visited, and :active instead.
No. Style links with CSS — for example a:active { color: … }. Learn alinkColor only to read or migrate old scripts.

Next: Document all

Learn the legacy document.all collection and why modern code avoids it.

all tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful