HTML DOM compatMode Property

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:



Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.