このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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 2015年7月.

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①

ブラウザーの互換性