JavaScript Document vlinkColor Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

document.vlinkColor gets or sets the color of visited links in the document — links the user has already opened (MDN).

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

Syntax

Use document.vlinkColor. Start with this line.

JavaScript
document.vlinkColor
CallWhat it does
document.vlinkColorPrimary signature.

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

Library declarations
JavaScript
document.vlinkColor

Parameters

ParameterDescription
Writable?Required. Getter and setter

Return Value

Return ValueDescription
*The current value of document.vlinkColor.

JavaScript Examples

Example 1 — Read vlinkColor

Log the current visited-link color string.

JavaScript
console.log(document.vlinkColor);
console.log(typeof document.vlinkColor);
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 purple #551a8b (MDN).
  4. Deprecated. Prefer CSS :visited in new work.

Example 2 — Set vlinkColor (Legacy)

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

JavaScript
document.vlinkColor = "purple";
console.log(document.vlinkColor);

document.vlinkColor = null;
console.log(document.vlinkColor); // ""
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 :visited

Modern replacement recommended by MDN.

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

console.log("using CSS :visited instead of vlinkColor");
Try It Yourself

How It Works

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

Browser Support

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

✓ Deprecated

Document.vlinkColor

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 #551a8b
Yes
Apple Safari Legacy support
Yes
Opera Legacy support
Yes
Internet Explorer Legacy support
Yes
vlinkColor Prefer CSS :visited

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

Frequently Asked Questions

It gets or sets the color of links that the user has visited in the document (MDN).
Yes. MDN marks Document.vlinkColor as Deprecated. Document color attributes are superseded by CSS. Prefer styling a:visited.
A string color name (such as red or purple) or a hexadecimal color (such as #551a8b). Setting null is converted to the empty string.
MDN notes the default vlinkColor in Mozilla Firefox is purple (#551a8b in hexadecimal).
Legacy Document properties include linkColor (unvisited), vlinkColor (visited), and alinkColor (active/pressed). Modern CSS uses :link, :visited, and :active instead.
No. Style visited links with CSS — for example a:visited { color: … }. Learn vlinkColor only to read or migrate old scripts.

Next: Document xmlEncoding

Learn the XML document encoding property and when it applies.

xmlEncoding 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