HTML DOM document contentType Property

The contentType property in HTML DOM returns the MIME type in which the document is being rendered. This is a read only property.

Syntax:

value = document.contentType;

Return value: This property returns a string value of MIME content type of the document.

Example: This example will show how to get the content MIME Type of the document using this property.

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <button onclick="get()">
        Get The Content Type
        of document
    </button>
  
    <script>
        function get() {
            alert(document.contentType);
        }
    </script>
</body>
  
</html>

chevron_right


Output:



    Before Click the Button:


    After Click the Button:

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

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.