废弃的元素(Element)
这个小节里列出的元素在 HTML5 里将不再使用,现有文档升级到 HTML5 的话可以使用一些替代方案。例如 parser section 可以处理 isindex 元素的功能。
下面的元素被废弃的原因是用 CSS 处理可以更好地替代他们:
- basefont
- big
- center
- font
- strike
- tt
下面的元素被废弃的原因是他们的使用破坏了可使用性和可访问性:
- frame
- frameset
- noframes
下面的元素被废弃的原因是不经常使用他们,也会引起混乱,而且其它元素也可以很好地实现他们的功能:
- acronym 被废弃是因为它经常使页面错乱,可以使用 abbr 代替
- applet 被废弃是因为可以使用 object 代替
- isindex 被废弃是因为使用表单控件代替
- dir 被废弃是因为使用 ul 代替
最后,noscript 元素只能在 HTML 里使用,而不能在 XML 里使用。
废弃的属性(Attribute)
HTML4 里的一些属性不会再被允许在 HTML5 里使用了,规范里详细说明了如何处理现有的文档,并且以后新文档不能再使用这些属性,因为他们会标记成不合法的属性。
HTML5 的规范里有对这些属性的代替方案,点击访问。
| ID | 对应元素 | 属性名称 |
|---|---|---|
| 01 | link, a | rev, charset |
| 02 | a | shape, coords |
| 03 | img, iframe | longdesc |
| 04 | link | target |
| 05 | area | nohref |
| 06 | head | profile |
| 07 | html | version |
| 08 | img | name |
| 09 | meta | scheme |
| 10 | object | archive, classid, codebase, codetype, declare, standby |
| 11 | param | valuetype, type |
| 12 | td, th | axis, abbr |
| 13 | td | scope |
| 14 | table | summary |
另外, 在 HTML5 里,以下元素的视觉属性也将被废弃,因为这些功能可用 CSS 来实现:
| ID | 对应元素 | 属性名称 |
|---|---|---|
| 01 | caption, iframe, img, input, object, legend, table, hr, div, h1, h2, h3, h4, h5, h6, p, col, colgroup, tbody, td, tfoot, th, thead, tr | align |
| 02 | body | alink, link, text, vlink |
| 03 | body | background |
| 04 | table, tr, td, th, body | bgcolor |
| 05 | object | border |
| 06 | table | cellpadding, cellspacing |
| 07 | col, colgroup, tbody, td, tfoot, th, thead, tr | char, charoff |
| 08 | br | clear |
| 09 | dl, menu, ol, ul | compact |
| 10 | table | frame |
| 11 | iframe | frameborder |
| 12 | td, th | height |
| 13 | img, object | hspace, vspace |
| 14 | iframe | marginheight, marginwidth |
| 15 | hr | noshade |
| 16 | td, th | nowrap |
| 17 | table | rules |
| 18 | iframe | scrolling |
| 19 | hr | size |
| 20 | li, ol, ul | type |
| 21 | col, colgroup, tbody, td, tfoot, th, thead, tr | valign |
| 22 | hr, table, td, th, col, colgroup, pre | width |