非常教程

HTML参考手册

标签 | Elements

u

HTML <u> 元素使文本在其内容的基线下的一行呈现下划线。在HTML5中, 此元素表示具有未标注的文本跨度,显示渲染,非文本注释,例如将文本标记为中文文本中的专有名称(一个正确的中文标记), 或 将文本标记为拼写错误。

内容类别

Flow content, phrasing content, palpable content.

允许的内容

Phrasing content

标记遗漏

没有,起始和结束标签都是强制性的。

允许的父级

任何接受 Phrasing content 的元素。

允许ARIA角色

任何

DOM接口

HTMLElement包括Gecko 1.9.2(Firefox 4),Firefox实现了这个元素的HTMLSpanElement接口。

属性

这个元素只包含全局属性。

使用说明

与所有纯粹的样式元素一样,<u>在HTML 4和XHTML 1中被弃用,但是随后在其他语义中被重新引入到HTML5中。如果要以非语义方式对文本进行下划线,则应使用<span>元素或其他语义适当的元素,并使用CSS text-decoration属性对underline值进行设置。

提示:避免使用<u>可能被混淆超链接的元素。

注意: HTML 5规范提醒开发人员其他元素几乎总是比较合适<u>

例子

以下是<u>应该如何使用元素以外的元素的示例。

<u>Today's Special</u>: Salmon<br />
<span style="text-decoration:underline;">Today's Special</span>:
  Salmon
<!-- Here <span> is used as the underlining is purely decorative
  and it is applied with CSS -->

Today's Special: Salmon

Today's Special: Salmon

<p><u>All</u> of that is explained in
  <u>Dive into Python</u></p>
<p><em>All</em> of that is explained in
  <i>Dive into Python</i></p>
<!-- Here the "All" is marked as stressed, using <em>,
  while "Dive into Python" is marked as a name using <i> --> 

All of that is explained in Dive into Python.

All of that is explained in Dive into Python.

由于默认的样式,<em>并且<i>已经以斜体显示,但是可以使用CSS来以正常的字体样式和下划线对这些元素进行样式设置。

规范

Specification

Status

Comment

HTML Living StandardThe definition of '<u>' in that specification.

Living Standard

HTML5The definition of '<u>' in that specification.

Recommendation

HTML 4.01 SpecificationThe definition of '<b>' in that specification.

Recommendation

浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

HTML

超文本标记语言,它通过标记符号来标记要显示的网页中的各个部分。网页文件本身是一种文本文件,通过在文本文件中添加标记符,可以告诉浏览器如何显示其中的内容(如:文字如何处理,画面如何安排,图片如何显示等)。浏览器按顺序阅读网页文件,然后根据标记符解释和显示其标记的内容,对书写出错的标记将不指出其错误,且不停止其解释执行过程,编制者只能通过显示效果来分析出错原因和出错部位。但需要注意的是,对于不同的浏览器,对同一标记符可能会有不完全相同的解释,因而可能会有不同的显示效果。