首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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>应该如何使用元素以外的元素的示例。

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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)

扫码关注腾讯云开发者

领取腾讯云代金券