萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網路程式設計 >> Java

HTML5 廢棄元素與屬性完整清單:遷移指南與替代方案

廢棄元素

1. 由 CSS 替代的表現類元素

  • basefont、big、center、font、strike、tt

2. 損害可用性/可訪問性的框架元素

  • frame、frameset、noframes

3. 使用稀少、易混淆、有更好替代的元素

  • acronym → 用 abbr
  • applet → 用 object
  • isindex → 用表單控件
  • dir → 用 ul

注意:noscript 僅可用於 HTML,不可用於 XML。

廢棄屬性(Attribute)

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

廢棄的視覺屬性(由 CSS 替代)

ID元素屬性
01caption, iframe, img, input, object, legend, table, hr, div, h1-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

遷移建議

  • 所有表現屬性改用 CSS(text-align、background-color、border、padding 等)。
  • 框架佈局改用 CSS Flexbox/Grid 或 iframe(僅嵌入第三方內容)。
  • 語義化標籤替代:abbr、object、ul。
  • 使用驗證工具(W3C Validator)檢測遺留廢棄特性。
copyright © 萬盛學電腦網 all rights reserved