Document.compatMode

The Document.compatMode property indicates whether the document is rendered in Quirks mode or Standards mode.

Syntax

const mode = document.compatMode

Value

An enumerated value that can be:

  • "BackCompat" if the document is in quirks mode.
  • "CSS1Compat" if the document is in no-quirks (also known as "standards") mode or limited-quirks (also known as "almost standards") mode.

Note: All these modes are now standardized, so the older "standards" and "almost standards" names are nonsensical and no longer used in standards.

Example

if (document.compatMode == "BackCompat") {
  // in Quirks mode
}

Specifications

Specification Status Comment
DOM
The definition of 'compatMode' in that specification.
Living Standard

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
compatMode
Non-standard
Chrome Full support 43Edge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 4.0

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.