Firefox Tomorrow

web api instance property

PreferenceManager: contrast property

View on MDN ↗

Limited availabilitySecure context

The contrast read-only property of the PreferenceManager interface returns a PreferenceObject used to override the user’s preference for the contrast of the site.

Valid contrast value settings are more, less, and no-preference.

Value

A PreferenceObject used to override the user’s preference for the contrast of the site.

Examples

Basic usage

This example demonstrates how to query the user’s contrast preference.

if (navigator.preferences.contrast.value === "more") {
  // The user prefers a high color contrast.
} else if (navigator.preferences.contrast.value === "less") {
  // The user prefers a low color contrast.
} else {
  // The user has stated no preference regarding color contrast.
}

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.