HTML <!DOCTYPE>


HTML 文档类型

所有 HTML 文档都必须以 <!DOCTYPE>宣言。

该声明不是 HTML 标记。对于浏览器来说,它是关于期望的文档类型的"information"。

在 HTML5 中,<!DOCTYPE>声明很简单:

<!DOCTYPE html>

在较旧的文档(HTML 4 或 XHTML)中,声明更为复杂,因为声明必须引用 DTD(文档类型定义)。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

您可以阅读有关文档类型的更多信息<!文档类型>参考。


不同 DOCTYPE 中的有效 HTML 元素

Tag HTML 5 HTML 4 XHTML
<a> Yes Yes Yes
<abbr> Yes Yes Yes
<acronym> No Yes Yes
<address> Yes Yes Yes
<applet> No Yes No
<area> Yes Yes No
<article> Yes No No
<aside> Yes No No
<audio> Yes No No
<b> Yes Yes Yes
<base> Yes Yes Yes
<basefont> No Yes No
<bdi> Yes No No
<bdo> Yes Yes No
<big> No Yes Yes
<blockquote> Yes Yes Yes
<body> Yes Yes Yes
<br> Yes Yes Yes
<button> Yes Yes Yes
<canvas> Yes No No
<caption> Yes Yes Yes
<center> No Yes No
<cite> Yes Yes Yes
<code> Yes Yes Yes
<col> Yes Yes No
<colgroup> Yes Yes No
<data> Yes No No
<datalist> Yes No No
<dd> Yes Yes Yes
<del> Yes Yes No
<details> Yes No No
<dfn> Yes Yes Yes
<dialog> Yes No No
<dir> No Yes No
<div> Yes Yes Yes
<dl> Yes Yes Yes
<dt> Yes Yes Yes
<em> Yes Yes Yes
<embed> Yes No No
<fieldset> Yes Yes Yes
<figcaption> Yes No No
<figure> Yes No No
<font> No Yes No
<footer> Yes No No
<form> Yes Yes Yes
<frame> No No No
<frameset> No Yes No
<h1> to <h6> Yes Yes Yes
<head> Yes Yes Yes
<header> Yes No No
<hr> Yes Yes Yes
<html> Yes Yes Yes
<i> Yes Yes Yes
<iframe> Yes Yes No
<img> Yes Yes Yes
<input> Yes Yes Yes
<ins> Yes Yes No
<kbd> Yes Yes Yes
<label> Yes Yes Yes
<legend> Yes Yes Yes
<li> Yes Yes Yes
<link> Yes Yes Yes
<main> Yes No No
<map> Yes Yes No
<mark> Yes No No
<meta> Yes Yes Yes
<meter> Yes No No
<nav> Yes No No
<noframes> No Yes No
<noscript> Yes Yes Yes
<object> Yes Yes Yes
<ol> Yes Yes Yes
<optgroup> Yes Yes Yes
<option> Yes Yes Yes
<output> Yes No No
<p> Yes Yes Yes
<param> Yes Yes Yes
<picture> Yes No No
<pre> Yes Yes Yes
<progress> Yes No No
<q> Yes Yes Yes
<rp> Yes No No
<rt> Yes No No
<ruby> Yes No No
<s> Yes Yes No
<samp> Yes Yes Yes
<script> Yes Yes Yes
<section> Yes No No
<select> Yes Yes Yes
<small> Yes Yes Yes
<source> Yes No No
<span> Yes Yes Yes
<strike> No Yes No
<strong> Yes Yes Yes
<style> Yes Yes Yes
<sub> Yes Yes Yes
<summary> Yes No No
<sup> Yes Yes Yes
<table> Yes Yes Yes
<tbody> Yes Yes No
<td> Yes Yes Yes
<template> Yes No No
<textarea> Yes Yes Yes
<tfoot> Yes Yes No
<th> Yes Yes Yes
<thead> Yes Yes No
<time> Yes No No
<title> Yes Yes Yes
<tr> Yes Yes Yes
<track> Yes No No
<tt> No Yes Yes
<u> Yes Yes No
<ul> Yes Yes Yes
<var> Yes Yes Yes
<video> Yes No No
<wbr> Yes No No