說起W3C標準頭部聲明、DTD 我居然第一時間想到的就是 DHTML 頭部聲明這些個東西、前端js寫了塊一年了這些個標準化的東西確所知甚少、下午閑來無事稍微整理了下分享出來不完整的地方希望大家能補充一下。
DTD 是一套關于標記符的語法規(guī)則。它是XML1.0版規(guī)格得一部分,是html文件的驗證機制,屬于html文件組成的一部分。
DTD:三種文檔類型:S(Strict)、T(Transitional)、F(Frameset)。
Strict:如果您需要干凈的標記,免于表現(xiàn)層的混亂,請使用此類型。請與層疊樣式表(CSS)配合使用
Transitional:DTD 可包含 W3C 所期望移入樣式表的呈現(xiàn)屬性和元素。如果您的讀者使用了不支持層疊樣式表(CSS)的瀏覽器以至于您不得不使用 HTML 的呈現(xiàn)特性時使用
Frameset: DTD 應當被用于帶有框架的文檔。除 frameset 元素取代了 body 元素之外,F(xiàn)rameset DTD 等同于 Transitional DTD
html5基本上沒有XHTML 1.0 Transitional嚴格的要求,并且簡化了很多東西可以直接使用 <!DOCTYPE HTML>
HTML5
<!DOCTYPE HTML>
——————————————————————————————
xhtml 1.1:
<!doctype html public "-/w3c/dtd xhtml 1.1/en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
xhtml 1.1 plus mathml plus svg:
<!doctype html public "-/w3c/dtd xhtml 1.1 plus mathml 2.0 plus svg 1.1/en" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
——————————————————————————————
html 4.01 strict:
<!doctype html public "-/w3c/dtd html 4.01/en" "http://www.w3.org/tr/html4/strict.dtd">
html 4.01 transitional:
<!doctype html public "-/w3c/dtd html 4.01 transitional/en" "http://www.w3.org/tr/html4/loose.dtd">
html 4.01 frameset:
<!doctype html public "-/w3c/dtd html 4.01 frameset/en" "http://www.w3.org/tr/html4/frameset.dtd">
——————————————————————————————
xhtml 1.0 strict:
<!doctype html public "-/w3c/dtd xhtml 1.0 strict/en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
xhtml 1.0 transitional:
<!doctype html public "-/w3c/dtd xhtml 1.0 transitional/en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
xhtml 1.0 frameset:
<!doctype html public "-/w3c/dtd xhtml 1.0 frameset/en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd">
——————————————————————————————
html 3.2:
<!doctype html public "-/w3c/dtd html 3.2 final/en">
——————————————————————————————
html 2(數(shù)字2代表版本號):
<!doctype html public "-/ietf/dtd html 2.0/en">
附上一張老版本標簽對照DTD文檔:
| 標簽 | 描述 | Dtd |
| <!DOCTYPE> | 定義文檔類型。 | STF |
| <html> | 定義 HTML 文檔。 | STF |
| <body> | 定義文檔的主體。 | STF |
| <h1> to <h6> | 定義 HTML 標題。 | STF |
| <p> | 定義段落。 | STF |
| <br> | 定義簡單的折行。 | STF |
| <hr> | 定義水平線。 | STF |
| <!--...--> | 定義注釋。 | STF |
| 標簽 | 描述 | Dtd |
| <b> | 定義粗體文本。 | STF |
| <font> | 不贊成使用。定義文本的字體、尺寸和顏色 | TF |
| <i> | 定義斜體文本。 | STF |
| <em> | 定義強調(diào)文本。 | STF |
| <big> | 定義大號文本。 | STF |
| <strong> | 定義語氣更為強烈的強調(diào)文本。 | STF |
| <small> | 定義小號文本。 | STF |
| <sup> | 定義上標文本。 | STF |
| <sub> | 定義下標文本。 | STF |
| <bdo> | 定義文本的方向。 | STF |
| <u> | 不贊成使用。定義下劃線文本。 | TF |
| 標簽 | 描述 | Dtd |
| <pre> | 定義預格式文本 | STF |
| <code> | 定義計算機代碼文本。 | STF |
| <tt> | 定義打字機文本。 | STF |
| <kbd> | 定義鍵盤文本。 | STF |
| <var> | 定義文本的變量部分。 | STF |
| <dfn> | 定義定義項目。 | STF |
| <samp> | 定義計算機代碼樣本。 | STF |
| <xmp> | 不贊成使用。定義預格式文本。 | |
| 標簽 | 描述 | Dtd |
| <acronym> | 定義只取首字母的縮寫。 | STF |
| <abbr> | 定義縮寫。 | STF |
| <address> | 定義文檔作者或擁有者的聯(lián)系信息。 | STF |
| <blockquote> | 定義塊引用。 | STF |
| <center> | 不贊成使用。定義居中文本。 | TF |
| <q> | 定義短的引用。 | STF |
| <cite> | 定義引用(citation)。 | STF |
| <ins> | 定義被插入文本。 | STF |
| <del> | 定義被刪除文本。 | STF |
| <s> | 不贊成使用。定義加刪除線的文本。 | TF |
| <strike> | 不贊成使用。定義加刪除線的文本。 | TF |
| 標簽 | 描述 | Dtd |
| <a> | 定義錨。 | STF |
| <link> | 定義文檔與外部資源的關系。 | STF |
| 標簽 | 描述 | Dtd |
| <frame> | 定義框架集的窗口或框架。 | F |
| <frameset> | 定義框架集。 | F |
| <noframes> | 定義針對不支持框架的用戶的替代內(nèi)容。 | TF |
| <iframe> | 定義內(nèi)聯(lián)框架。 | TF |
| 標簽 | 描述 | Dtd |
| <form> | 定義供用戶輸入的 HTML 表單。 | STF |
| <input> | 定義輸入控件。 | STF |
| <textarea> | 定義多行的文本輸入控件。 | STF |
| <button> | 定義按鈕。 | STF |
| <select> | 定義選擇列表(下拉列表)。 | STF |
| <optgroup> | 定義選擇列表中相關選項的組合。 | STF |
| <option> | 定義選擇列表中的選項。 | STF |
| <label> | 定義 input 元素的標注。 | STF |
| <fieldset> | 定義圍繞表單中元素的邊框。 | STF |
| <legend> | 定義 fieldset 元素的標題。 | STF |
| <isindex> | 不贊成使用。定義與文檔相關的可搜索索引。 | TF |
| 標簽 | 描述 | Dtd |
| <ul> | 定義無序列表。 | STF |
| <ol> | 定義有序列表。 | STF |
| <li> | 定義列表的項目。 | STF |
| <dir> | 不贊成使用。定義目錄列表。 | TF |
| <dl> | 定義定義列表。 | STF |
| <dt> | 定義定義列表中的項目。 | STF |
| <dd> | 定義定義列表中項目的描述。 | STF |
| <menu> | 不贊成使用。定義菜單列表。 | TF |
| 標簽 | 描述 | Dtd |
| <img> | 定義圖像。 | STF |
| <map> | 定義圖像映射。 | STF |
| <area> | 定義圖像地圖內(nèi)部的區(qū)域。 | STF |
| 標簽 | 描述 | Dtd |
| <table> | 定義表格 | STF |
| <caption> | 定義表格標題。 | STF |
| <th> | 定義表格中的表頭單元格。 | STF |
| <tr> | 定義表格中的行。 | STF |
| <td> | 定義表格中的單元。 | STF |
| <thead> | 定義表格中的表頭內(nèi)容。 | STF |
| <tbody> | 定義表格中的主體內(nèi)容。 | STF |
| <tfoot> | 定義表格中的表注內(nèi)容(腳注)。 | STF |
| <col> | 定義表格中一個或多個列的屬性值。 | STF |
| <colgroup> | 定義表格中供格式化的列組。 | STF |
| 標簽 | 描述 | Dtd |
| <style> | 定義文檔的樣式信息。 | STF |
| <div> | 定義文檔中的節(jié)。 | STF |
| <span> | 定義文檔中的節(jié)。 | STF |
| 標簽 | 描述 | Dtd |
| <head> | 定義關于文檔的信息。 | STF |
| <title> | 定義文檔的標題。 | STF |
| <meta> | 定義關于 HTML 文檔的元信息。 | STF |
| <base> | 定義頁面中所有鏈接的默認地址或默認目標。 | STF |
| <basefont> | 不贊成使用。定義頁面中文本的默認字體、顏色或尺寸。 | TF |
| 標簽 | 描述 | Dtd |
| <script> | 定義客戶端腳本。 | STF |
| <noscript> | 定義針對不支持客戶端腳本的用戶的替代內(nèi)容。 | STF |
| <applet> | 不贊成使用。定義嵌入的 applet。 | TF |
| <object> | 定義嵌入的對象。 | STF |
| <param> | 定義對象的參數(shù)。 | STF |

