JavaScript Document linkColor Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.linkColor gets or sets the color of links within the document (MDN)—historically the unvisited link color.

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

Syntax

Use document.linkColor. Start with this line.

JavaScript
document.linkColor
CallWhat it does
document.linkColorPrimary signature.

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

Library declarations
JavaScript
document.linkColor

Parameters

ParameterDescription
Writable?Required. Getter and setter

Return Value

Return ValueDescription
*The current value of document.linkColor.

JavaScript Examples

Example 1 — Read linkColor

Log the current unvisited-link color string.

JavaScript
console.log(document.linkColor);
console.log(typeof document.linkColor);
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 blue #0000ee (MDN).
  4. Deprecated. Prefer CSS / computed style in new work.

Example 2 — Set linkColor (Legacy)

Assign a color name or hex. MDN example uses "blue".

JavaScript
document.linkColor = "blue";
console.log(document.linkColor);

document.linkColor = null;
console.log(document.linkColor); // ""
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 it).
  3. Assign null. MDN: converted to "".
  4. Do not ship this. Use CSS for production styling.

Example 3 — Prefer CSS :link

Modern replacement recommended by MDN.

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

console.log("using CSS :link instead of linkColor");
Try It Yourself

How It Works

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

Browser Support

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

✓ Deprecated

Document.linkColor

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 #0000ee
Yes
Apple Safari Legacy support
Yes
Opera Legacy support
Yes
Internet Explorer Legacy support
Yes
linkColor Prefer CSS :link

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

Frequently Asked Questions

It gets or sets the color of links within the document — historically the unvisited-link color. MDN recommends CSS instead.
Yes. MDN marks Document.linkColor as deprecated. Document color attributes are superseded by CSS. Prefer a:link { color: … } or styling anchor elements.
A string color name (such as blue) or a hexadecimal value (such as #ff0000). Setting null is converted to the empty string (MDN).
MDN notes the default linkColor in Mozilla Firefox is blue (#0000ee in hexadecimal).
linkColor styles unvisited links. vlinkColor styles visited links. alinkColor styles active (pressed) links. Modern CSS uses :link, :visited, and :active instead.
No. Style links with CSS — for example a:link { color: … }. Learn linkColor only to read or migrate old scripts.

Next: links

Learn the document’s live collection of hyperlink elements.

links 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.

9 people found this page helpful