Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

這些已廢棄的 HTML 標籤,別再用了

HTML 走過多年演進,W3C 已發布 HTML 5.1 的提案推薦標準,一批陳舊標籤正在後續標準中逐步退場。以下列出那些已被廢棄的標籤,看看你是否還在用。

<acronym>

首字母縮寫,例如 WWW。類似的

<abbr>
表示單字縮寫,例如
<abbr>inc.</abbr>
。

<acronym title="World Wide Web">WWW</acronym>
<abbr title="incorporated">inc.</abbr>

建議用

<abbr>
,不要用
<acronym>
。

<applet>

Java 小程式,主要提供繪圖功能:

<applet code="ShowImage.class" width=600 height=400 archive="Imagetest.jar"></applet>

目前幾乎沒人用了,因為執行需要 JRE,而主流瀏覽器預設不裝。建議改用

<canvas>
繪圖,或用
<object>
+
<embed>
嵌入 Flash 代替。若情境允許,優先選
<object>
。

<basefont>

定義基準字體,可為整份文件設定預設顏色、大小與字型:

<basefont color="red" size="5" face="Arial" />

只有 IE 支援。建議直接在

<body>
上定義,子元素會自動繼承。

<bgsound>

<bgsound src="your.mid" autostart="true" loop="infinite">

建議改用

<audio>
或
<object>
+
<embed>
。

<big>

<big>大1號</big><big><big>大2號</big></big>

不建議使用,請依語義選

<em>
、
<strong>
或自訂樣式類別。

<blink>

<blink>Why would somebody use this?</blink>

支援性極差,建議改用

<animation>
。

<center>

<center>文本及子元素會居中</center>

效果等同 CSS 的

text-align: center;
,真的沒有理由再用。

<dir>

<dir>
 <li>html</li>
 <li>xhtml</li>
 <li>css</li>
</dir>

效果與

<ul>
幾乎相同,建議依語義改用
<ul>
、
<ol>
或
<dl>
。

<font>

<font face="verdana" color="green" size="3">This is some text!</font>

請用 CSS 代替。

<frame> 與 <frameset>

<!DOCTYPE html>
<html>
<frameset cols="25%,*,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
</html>

注意此處用

<frameset>
取代了
<body>
。複雜後台頁面確實曾用這種布局,如今可用 float/flex + Ajax 達成,依情境決定。

<hgroup>

<hgroup>
 <h1>The reality dysfunction</h1>
 <h2>Space is not the only void</h2>
</hgroup>

建議改用

<header>
:

<header>
 <h1>The reality dysfunction</h1>
 <p class="subheading">Space is not the only void</p>
</header>

<isindex>

<isindex prompt="string" />

支援性很差,建議用

<input>
代替。W3C 甚至直接寫道:No, really, don't use it.

<listing>

微軟都不建議使用了:Use HTMLPreElement, code or CSS instead.

<marquee>

<marquee bgcolor="#ccffff" vspace="10" direction="up" height="104"
 width="22.35%" loop="3" scrollamount="1" scrolldelay="10" hspace="20">
 <p align="center"><font color="#000000">此處輸入滾動內容</font></p>
</marquee>

多用來做公告,雖然過時但效果強大且支援良好。

<multicol>

多列布局,從未被任何主流瀏覽器實作過,不建議使用。

<nextid>

作用與支援性皆不明,不建議使用。

<nobr>

<p>Our telephone number is <nobr>0800 123 123 123</nobr>.</p>

建議改用 CSS:

white-space: nowrap;

<noembed>

在瀏覽器不支援

<embed>
時顯示替代內容,類似
<noscript>
。若需兼顧相容性,建議
<object>
+
<embed>
+
<noembed>
三層回退。

<noframes>

<html>
<frameset cols="25%,50%,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
<noframes>Sorry, your browser does not handle frames!</noframes>
</frameset>
</html>

裡面可包含任何能出現在

<body>
中的標籤,作為
<frame>
的回退。

<plaintext>

忽略內容中的 HTML 標籤,作用類似

<pre>
。建議依語義改用
<pre>
或
<code>
。

<spacer>

<span>Just a text node</span>
<spacer type="horizontal" size="10"></spacer>
<span>Just another text node</span>

主流瀏覽器皆不支援。

<strike>

<p>Version 2.0 is <strike>not yet available!</strike> now available!</p>

建議改用

<del>
。

<tt>

<p><tt>Teletype text</tt></p>

建議依語義改用

<kbd>
(按鍵)、
<var>
(變數)、
<code>
(程式碼)、
<samp>
(範例輸出)或 CSS。

<xmp>

<xmp>
Stock ID  Description        Price  Quantity in Stock
--------  -----------        -----  -----------------
116       Inflatable Armchair  21.50  13
119       Walkie Talkie        40.20  44
</xmp>

目前瀏覽器仍支援,但不再限制 80 列。建議改用

<samp>
。

Copyright © Linux教程網 All Rights Reserved