JavaScript Document vlinkColor Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Instance property

What You’ll Learn

Document.vlinkColor is a deprecated instance property that gets or sets the color of visited links in the document. Learn what visited links are, how it fits with legacy linkColor and alinkColor, the modern :visited CSS replacement, and five examples with try-it labs.

01

Kind

Instance property

02

Type

string color

03

Status

Deprecated

04

Means

Visited link

05

Replace

CSS :visited

06

Legacy set

link / alink

Introduction

Browsers remember which links you have opened. A visited link is a hyperlink whose destination URL is already in the user’s browsing history for this site. Visited links often appear in a different color—traditionally purple.

MDN: the vlinkColor property gets/sets the color of links that the user has visited in the document. Like other legacy Document color properties, it comes from the early HTML era when pages styled links globally from JavaScript or <body vlink="..."> attributes.

💡
Learn it, don’t ship it

Study vlinkColor so you can recognize legacy scripts and old tutorials. For new pages, style visited links with CSS: a:visited { color: ... } alongside :link, :hover, and :active.

Related Document tutorials: linkColor, alinkColor, links, Document constructor.

Understanding Document.vlinkColor

A getter/setter instance property on Document. Reading it returns the visited-link color string; writing it changes the color applied to visited links in the document body.

  • Value — a color name (purple, darkviolet) or hex (#551a8b).
  • Visited state — links the user has already opened in browsing history.
  • null — assigning null converts to "" (empty string, MDN).
  • Firefox default — MDN: purple (#551a8b) in Mozilla Firefox.
  • Deprecated — MDN recommends CSS a:visited { color: ... } instead.

📝 Syntax

JavaScript
document.vlinkColor

Get

JavaScript
console.log(document.vlinkColor);
// e.g. "#551a8b" in Firefox (MDN default)

Set

JavaScript
document.vlinkColor = "purple";
document.vlinkColor = "#551a8b";
document.vlinkColor = null; // becomes ""

⚡ Quick Reference

GoalCode / note
Read visited colordocument.vlinkColor
Set named colordocument.vlinkColor = "purple"
Firefox default (MDN)#551a8b
Clear (legacy)document.vlinkColor = null""
Modern replacementa:visited { color: ... }
MDN statusDeprecated

🔍 At a Glance

Four facts about document.vlinkColor.

Type
string

Color value

When
visited

Already opened

Status
deprecated

Legacy API

Use CSS
:visited

Modern fix

📋 vlinkColor vs a:visited

document.vlinkColora:visited { color: ... }
ScopeDocument-wide legacy hookPer-stylesheet CSS rule
Recommended?NoYes
MDN statusDeprecatedStandard CSS
Best forReading old codeAll new styling

Examples Gallery

Examples follow MDN Document: vlinkColor. Open try-it labs to see visited-link colors where the property still applies.

📚 Getting Started

Read and set the deprecated visited-link color.

Example 1 — Read document.vlinkColor

Log the current visited-link color (browser-dependent).

JavaScript
console.log(document.vlinkColor);
// Firefox default (MDN): "#551a8b"
// Other browsers may differ or ignore the property in practice
Try It Yourself

How It Works

The returned string may be a hex code or color name depending on how the browser stores it.

Example 2 — Set "purple" for Visited Links

Assign a named color for links the user has already opened.

JavaScript
document.vlinkColor = "purple";
console.log(document.vlinkColor);
// Visited links appear purple where the property is honored
Try It Yourself

How It Works

Only links in the visited state use this color. Unvisited links still follow linkColor or CSS :link.

📈 Hex, null & Modern CSS

Other assignment forms and the recommended replacement.

Example 3 — Set Firefox Default Hex #551a8b

MDN’s documented default purple in hexadecimal form.

JavaScript
document.vlinkColor = "#551a8b";
console.log(document.vlinkColor);
Try It Yourself

How It Works

This is the classic “visited link purple” from early web design. CSS :visited is the modern equivalent.

Example 4 — null Becomes Empty String

MDN: assigning null is equivalent to assigning "".

JavaScript
document.vlinkColor = null;
console.log(document.vlinkColor === "");
console.log(JSON.stringify(document.vlinkColor));
Try It Yourself

How It Works

Legacy Document color properties share this null-to-empty-string quirk (MDN).

Example 5 — Modern Replacement: CSS :visited

Style visited links with standard CSS instead of vlinkColor.

CSS
a:link { color: #2563eb; }
a:visited { color: #551a8b; }
a:active { color: #dc2626; }
Try It Yourself

How It Works

MDN’s recommended alternative. Works in all modern browsers and fits design systems.

🚀 Why This Property Existed

  • Legacy intranet pages — old scripts that set global link colors from JavaScript.
  • Migration audits — find vlinkColor assignments and replace with CSS.
  • Reading tutorials — understand 1990s–2000s HTML/JS link styling.
  • Pair with linkColor — unvisited vs visited were separate Document hooks.
  • Not for production — use :visited in stylesheets instead.
  • Accessibility — ensure visited and unvisited links remain distinguishable in CSS.

🧠 How Legacy Link Colors Worked

1

Page loads with links

Unvisited links use linkColor or CSS :link.

Unvisited
2

User opens a link

Browser marks the URL as visited in history.

History
3

vlinkColor applies

Visited links render with the Document visited color (legacy).

Visited
4

Today: use CSS :visited

MDN recommends pseudo-classes on <a> instead of Document properties.

📝 Notes

  • MDN: Deprecated — avoid in new code; use CSS :visited.
  • Firefox default visited color: #551a8b (MDN).
  • document.vlinkColor = null becomes "" (MDN).
  • Visited styling has privacy restrictions in modern CSS—only certain properties are allowed on :visited.
  • Related: linkColor, alinkColor, links.

Legacy Browser Support

Document.vlinkColor is deprecated but may still exist for compatibility in some browsers. MDN recommends CSS :visited instead. Logos use the shared browser-image-sprite.png sprite from this project.

Deprecated · Legacy

Document.vlinkColor

Legacy visited-link color getter/setter — use CSS :visited in new code.

Legacy Compatibility only
Mozilla Firefox Supported · default #551a8b (MDN)
Legacy support
Google Chrome May expose property · prefer CSS
Legacy / limited
Apple Safari Do not rely on vlinkColor
Legacy / limited
Microsoft Edge Chromium · prefer CSS :visited
Legacy / limited
Opera Follow Chromium behavior
Legacy / limited
Internet Explorer Legacy Document color APIs
Legacy support
Document.vlinkColor Avoid in new code

Bottom line: Recognize vlinkColor in old scripts. For new styling, use a:link, a:visited, a:hover, and a:active in CSS — never document.vlinkColor.

Conclusion

Document.vlinkColor is a deprecated way to control the color of visited links in a document. It is useful for understanding legacy pages and migrating them to CSS—not for new features.

Continue with links, linkColor, alinkColor, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Style visited links with CSS a:visited { color: ... }
  • Keep visited and unvisited colors visually distinct
  • Replace vlinkColor when updating legacy files
  • Learn the linkColor / vlinkColor / alinkColor trio for old code
  • Test link states in real browsers after migrating to CSS

❌ Don’t

  • Set document.vlinkColor in new production code
  • Confuse visited with unvisited or active states
  • Assume the same default purple in every browser
  • Override :visited with properties browsers block for privacy
  • Depend on vlinkColor for accessibility contrast

Key Takeaways

Knowledge Unlocked

Five things to remember about vlinkColor

Deprecated visited-link color — prefer CSS :visited.

5
Core concepts
⚠️02

Status

deprecated

Legacy
🔗03

When

visited

State
04

Replace

a:visited

CSS
🔄05

Firefox

#551a8b

MDN

❓ Frequently Asked Questions

It gets or sets the color of visited links in the document — hyperlinks the user has already opened in the current browsing history.
Yes. MDN marks Document.vlinkColor as deprecated in the HTML specification. It may still exist for compatibility in some browsers, but you should use CSS a:visited { color: ... } in new code.
A string color name (such as purple or darkviolet) or a hexadecimal color (such as #551a8b). Setting null is converted to the empty string per MDN.
MDN notes the default vlinkColor in Mozilla Firefox is purple (#551a8b in hexadecimal).
linkColor styles unvisited links. vlinkColor styles visited links. alinkColor styles active links while the mouse button is held down. Modern CSS uses :link, :visited, and :active instead.
No. Style visited links with CSS — for example a:visited { color: ... } — or component styles. Learn vlinkColor only to read or migrate old scripts.
Did you know?

The “v” in vlinkColor stands for visited. It paired with linkColor (unvisited) and alinkColor (active) on the old <body link="" vlink="" alink=""> attributes—all replaced today by CSS pseudo-classes.

Next: links

Learn the live HTMLCollection of every hyperlink with an href.

links →

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.

6 people found this page helpful