This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
The Document.contentType read-only property returns the MIME type that the document is being rendered as. This may come from HTTP headers or other sources of MIME information, and might be affected by automatic type conversions performed by either the browser or extensions.
Note: This property is unaffected by <meta> elements.
contentType is a read-only property.
| Specification |
|---|
| DOM> # ref-for-dom-document-contenttype①> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
contentType |
36 | 17 | 1 | 23≤12.1–15 | 9 | 36 | 4 | 24≤12.1–14 | 9 | 3.0 | 37 | 9 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/contentType