Document: doctype プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

doctypeDocument インターフェイスの読み取り専用プロパティで、現在の文書に関連付けられた Document Type Declaration (DTD) を表す DocumentType オブジェクトです。

DocumentType オブジェクトです。

js
const doctypeObj = document.doctype;

console.log(`doctypeObj.name: ${doctypeObj.name}`);
console.log(`doctypeObj.internalSubset: ${doctypeObj.internalSubset}`);
console.log(`doctypeObj.publicId: ${doctypeObj.publicId}`);
console.log(`doctypeObj.systemId: ${doctypeObj.systemId}`);

メモ

現在の文書に関連付けられている DTD が存在しないは null が返されます。

DOM レベル 2 では、文書型宣言の編集に対応していません。

仕様書

Specification
DOM
# ref-for-dom-document-doctype①

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
doctype

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support