代码改变世界

HTML5学习笔记简明版(10):废弃的元素和属性

2011-12-17 20:36  汤姆大叔  阅读(4615)  评论(0编辑  收藏  举报

废弃的元素(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

对应元素

属性名称

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