HTMLCSS学习笔记

废弃的元素(Element)

这个小节里列出的元素在 HTML5 里将不再使用,现有文档升级到 HTML5 的话可以使用一些替代方案。例如 parser section 可以处理 isindex 元素的功能。

下面的元素被废弃的原因是用 CSS 处理可以更好地替代他们:

  1. basefont
  2. big
  3. center
  4. font
  5. strike
  6. tt

下面的元素被废弃的原因是他们的使用破坏了可使用性和可访问性:

  1. frame
  2. frameset
  3. noframes

下面的元素被废弃的原因是不经常使用他们,也会引起混乱,而且其它元素也可以很好地实现他们的功能:

  • acronym 被废弃是因为它经常使页面错乱,可以使用 abbr 代替
  • applet 被废弃是因为可以使用 object 代替
  • isindex 被废弃是因为使用表单控件代替
  • dir 被废弃是因为使用 ul 代替

最后,noscript 元素只能在 HTML 里使用,而不能在 XML 里使用。

废弃的属性(Attribute)

HTML4 里的一些属性不会再被允许在 HTML5 里使用了,规范里详细说明了如何处理现有的文档,并且以后新文档不能再使用这些属性,因为他们会标记成不合法的属性。

HTML5 的规范里有对这些属性的代替方案,点击访问

ID对应元素属性名称
01link, arev, charset
02ashape, coords
03img, iframelongdesc
04linktarget
05areanohref
06headprofile
07htmlversion
08imgname
09metascheme
10objectarchive, classid, codebase, codetype, declare, standby
11paramvaluetype, type
12td, thaxis, abbr
13tdscope
14tablesummary

另外, 在 HTML5 里,以下元素的视觉属性也将被废弃,因为这些功能可用 CSS 来实现:

ID对应元素属性名称
01caption, iframe, img, input, object, legend, table, hr, div, h1, h2, h3, h4, h5, h6, p, col, colgroup, tbody, td, tfoot, th, thead, tralign
02bodyalink, link, text, vlink
03bodybackground
04table, tr, td, th, bodybgcolor
05objectborder
06tablecellpadding, cellspacing
07col, colgroup, tbody, td, tfoot, th, thead, trchar, charoff
08brclear
09dl, menu, ol, ulcompact
10tableframe
11iframeframeborder
12td, thheight
13img, objecthspace, vspace
14iframemarginheight, marginwidth
15hrnoshade
16td, thnowrap
17tablerules
18iframescrolling
19hrsize
20li, ol, ultype
21col, colgroup, tbody, td, tfoot, th, thead, trvalign
22hr, table, td, th, col, colgroup, prewidth