Open In App

HTML DOM compatMode Property

Last Updated : 08 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The compatMode property in HTML DOM indicates the mode in which the document is rendered, exp Quirks mode or Standards mode.

Syntax:

var mode = document.compatMode;

Return Value:

  • Returns BackCompat if the document is rendered in quirks mode.
  • Returns CSS1Compat if the document is rendered in standards mode or limited-quirks (also known as “almost standards”) mode.

Example: In this example, we will get the document mode using this property.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <script>
        console.log("The Rendering Mode is");
        if (document.compatMode == "BackCompat") {
            console.log("Quirks Mode");
        }
        else {
            console.log("Standards Mode");
        }
    </script>
</body>
 
</html>


Output:

Supported Browsers:

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Internet Explorer 6
  • Opera 12.1
  • Safari 3.1

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads