- 持续更新中…
A
a (超链接、链接到其他)
<a>
HTML元素(或锚元素),用它的href
属性,创建 一个超链接 到网页,文件,电子邮件地址,同一页面中的位置,或任何其他 URL可以处理的东西。每个<a>
中的内容 应该表明 链接的目的地。如果存在href
属性,则在聚焦<a>
元素时 按 enter 键 将激活它。- The
<a>
HTML element (or anchor element), with itshref
attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address. Content within each<a>
should indicate the link’s destination. If thehref
attribute is present, pressing the enter key while focused on the<a>
element will activate it.
abbr (缩写、首字母缩写、title 完整描述)
<abbr>
HTML元素表示 缩写或首字母缩写;可选的title
属性 可以提供 缩写的 展开或描述。如果存在,标题必须包含 完整的描述,而不是 其他内容。- The
<abbr>
HTML element represents an abbreviation or acronym; the optional title attribute can provide an expansion or description for the abbreviation. If present, title must contain this full description and nothing else.
address (作者、版权所有者、任何 联系信息)
<address>
HTML元素表示 所包含的 HTML 提供了 一个人或几个人或一个组织的 联系信息。<address>
元素的内容 提供的联系信息 可以采用适合语境的任何形式,并且可以包括 所需的 任何类型的 联系信息,例如 物理地址、URL、电子邮件地址、电话号码、社会媒体账号、地理坐标 等等。<address>
元素应该包含 联系人信息 所指向的人员、人员或组织的名称。<address>
可以在各种语境中使用,例如 在页眉中 提供企业的联系信息,或者通过在<article>
中包含<address>
元素来指示 文章的作者。- The
<address>
HTML element indicates that the enclosed HTML provides contact information for a person or people, or for an organization. - The contact information provided by an
<address>
element’s contents can take whatever form is appropriate for the context, and may include any type of contact information that is needed, such as a physical address, URL, email address, phone number, social media handle, geographic coordinates, and so forth. The<address>
element should include the name of the person, people, or organization to which the contact information refers. <address>
can be used in a variety of contexts, such as providing a business’s contact information in the page header, or indicating the author of an article by including an<address>
element within the<article>
.
B
b (黑体、注意力吸引)
-
<b>
HTML元素用于 将读者的 注意力吸引 到元素的内容上,这些内容 不会在其他方面 被赋予特别的重要性。这以前被称为 bold 元素,大多数浏览器仍然用 黑体绘制文本。然而,你不应该使用<b>
来样式化文本;相反,您应该使用 CSSfont-weight
属性 来创建 粗体文本,或者使用<strong>
元素来指示文本的 特殊重要性。 -
The
<b>
HTML element is used to draw the reader’s attention to the element’s contents, which are not otherwise granted special importance. This was formerly known as the Boldface element, and most browsers still draw the text in boldface. However, you should not use<b>
for styling text; instead, you should use the CSSfont-weight
property to create boldface text, or the<strong>
element to indicate that text is of special importance.
bdo (覆盖、文本书写方向)
<bdo>
HTML元素覆盖 文本的当前方向,以便其中的文本 以不同的方向 呈现。- 文本的字符 是从给定方向的起始点 绘制的;单个角色的方向 不会受到影响(例如,角色不会向后绘制)
- The
<bdo>
HTML element overrides the current directionality of text, so that the text within is rendered in a different direction. - The text’s characters are drawn from the starting point in the given direction; the individual characters’ orientation is not affected (so characters don’t get drawn backward, for example).
blockquote (长引用、cite属性 url、缩进)
<blockquote>
HTML元素表示 所包含的文本 是一个扩展的引用。通常,这是通过缩进 在视觉上呈现的(有关如何更改它,请参阅注释)。可以使用cite
属性给出引用源的URL
,而可以使用<cite>
元素给出引用源的 文本表示形式。- The
<blockquote>
HTML element indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the<cite>
element.
body(文档内容、仅一个)
-
<body>
HTML元素 表示 HTML 文档的 内容。一个文档中 只能有一个<body>
元素。 -
The
<body>
HTML element represents the content of an HTML document. There can be only one<body>
element in a document.
br(换行符、文本中断)
-
<br>
HTML元素 在文本中 产生 一个换行符(回车)。它在写诗或演讲时很有用,在这些地方,线条的划分很重要。 -
从上面的示例中 可以看到,在我们希望 文本中断 的每个位置 都包含了一个
<br>
元素。<br>
之后的文本 再次从文本块的下一行开始。 -
注意:不要使用
<br>
在段落之间创建 页边距;将它们包裹在<p>
元素中,并使用 CSSmargin
属性控制它们的大小。 -
The
<br>
HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant. -
As you can see from the above example, a
<br>
element is included at each point where we want the text to break. The text after the<br>
begins again at the start of the next line of the text block. -
Note: Do not use
<br>
to create margins between paragraphs; wrap them in<p>
elements and use the CSS margin property to control their size.
C
cite
<cite>
HTML元素用于描述对 被引用的创造性作品的 参考文献,并且必须包括该 作品的标题。根据 与引用的元数据相关的 合适语境下的惯例,参考文献 可以采用缩写形式。- The
<cite>
HTML element is used to describe a reference to a cited creative work, and must include the title of that work. The reference may be in an abbreviated form according to context-appropriate conventions related to citation metadata.
code (计算机代码、等宽)
<code>
HTML元素 以某种方式 显示其内容的样式,以表明 文本是 计算机代码 的一小段。默认情况下,内容文本 使用用户代理的 默认 等宽字体 显示。- The
<code>
HTML element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code. By default, the content text is displayed using the user agent’s default monospace font.
D
del (已删除 文本)
-
<del>
HTML元素表示 已从文档中 删除的 一批文本。例如,这可以在呈现“跟踪更改”或 “源代码 差异信息”时使用。<ins>
元素可以用于相反的目的:指示已添加到文档中的文本。 -
此元素通常(但不需要)通过对文本应用 中间划线样式 来呈现。
-
The
<del>
HTML element represents a range of text that has been deleted from a document. This can be used when rendering “track changes” or source code diff information, for example. The<ins>
element can be used for the opposite purpose: to indicate text that has been added to the document. -
This element is often (but need not be) rendered by applying a strike-through style to the text.
dfn (被定义的 术语名、术语定义 = title 属性值、父标签内容)
-
<dfn>
HTML元素用于 指示 在定义短语、句子的语境中 被定义的术语名。<p>
元素的内容、<dt>/<dd>
标签对中<dd>
标签的内容,或者与<dfn>
最近的 父标签( 如<section>
)元素的内容 被认为是术语的定义。 -
The
<dfn>
HTML element is used to indicate the term being defined within the context of a definition phrase or sentence. The<p>
element, the<dt>/<dd>
pairing, or the<section>
element which is the nearest ancestor of the<dfn>
is considered to be the definition of the term.
div (块级容器、内容分组、样式化)
-
<div>
HTML元素是 流内容的 通用容器。它 对 内容或布局 没有影响,直到使用 CSS 以某种方式 进行样式化(例如,样式直接应用于它,或者将某种布局模型(如Flexbox
)应用于其父元素)。 -
作为一个“纯”容器,
<div>
元素本身并不表示任何东西。相反,它用于 对内容 进行分组,以便可以使用class
或id
属性轻松地对其进行 样式化,将文档的一部分标记为用不同的语言编写(使用lang
属性),等等。 -
The
<div>
HTML element is the generic container for flow content. It has no effect on the content or layout until styled in some way using CSS (e.g. styling is directly applied to it, or some kind of layout model likeFlexbox
is applied to its parent element).
As a “pure” container, the<div>
element does not inherently represent anything. Instead, it’s used to group content so it can be easily styled using theclass
orid
attributes, marking a section of a document as being written in a different language (using thelang
attribute), and so on.
dd (描述、定义、值)
<dd>
HTML元素在描述列表(<dl>
)中为前面的术语(<dt>
)提供 描述、定义或值。- The
<dd>
HTML element provides the description, definition, or value for the preceding term (<dt>
) in a description list (<dl>
).
dl (定义列表、描述列表、术语表、键值对)
<dl>
HTML元素表示 一个描述列表。元素包含一组术语(使用<dt>
元素指定)和描述(由<dd>
元素提供)的列表。此元素的常见用途是 实现术语表 或 显示元数据(键值对 列表)。- The
<dl>
HTML element represents a description list. The element encloses a list of groups of terms (specified using the<dt>
element) and descriptions (provided by<dd>
elements). Common uses for this element are to implement a glossary or to display metadata (a list of key-value pairs).
dt (术语名)
-
<dt>
HTML元素 在描述或定义列表中 指定术语,因此 必须在<dl>
元素中使用。通常后面跟一个<dd>
元素; -
但是,一行中的多个
<dt>
元素表示 多个术语都由 最近的 下一个<dd>
元素定义。随后的<dd>
(Description Details)元素 提供 与使用<dt>
指定的术语 相关联的 定义或其他相关文本。 -
The
<dt>
HTML element specifies a term in a description or definition list, and as such must be used inside a<dl>
element. It is usually followed by a<dd>
element; -
however, multiple
<dt>
elements in a row indicate several terms that are all defined by the immediate next<dd>
element. The subsequent<dd>
(Description Details) element provides the definition or other related text associated with the term specified using<dt>
.
E
em(着重强调、可嵌套)
<em>
HTML元素 标记具有 着重强调的文本。<em>
元素可以嵌套,每一层嵌套 表示更大程度的强调。- The
<em>
HTML element marks text that has stress emphasis. The<em>
element can be nested, with each level of nesting indicating a greater degree of emphasis.
F
form(提交信息)
<form>
HTML元素表示 包含用于 提交信息的 交互式控件的 文档部分。- 可以使用
:valid
和:invalid
CSS 伪类 根据表单内的元素 是否有效 来为<form>
元素 设置样式。 - The
<form>
HTML element represents a document section containing interactive controls for submitting information. - It is possible to use the
:valid
and:invalid
CSS pseudo-classes to style a
<form>
element based on whether or not the elements inside the form are valid.
h
head (机器可读、元数据、机器处理)
-
<head>
HTML元素包含 关于文档的 机器可读信息(元数据),比如 它的标题、脚本和样式表。 -
注意:主要保存 机器处理的 信息,而不是 人类的可读性。对于 人类可见的 信息,如顶级标题、列出的作者,请参阅
<header>
元素。 -
The
<head>
HTML element contains machine-readable information (metadata ) about the document, like its title , scripts , and style sheets . -
Note:
<head>
primarily holds information for machine processing, not human-readability. For human-visible information, like top-level headings and listed authors, see the<header>
element.
hr (主题中断、主题转移、语义术语)
-
<hr>
HTML元素表示 段落级元素 之间的 “主题中断”:例如,故事中场景的变化,或者一个部分中的 主题的转移。 -
从历史上看,这是一条水平的规则或线。虽然在可视浏览器中 它可能仍然显示为水平线,但是这个元素 现在是用作 语义术语 而不是 表示术语 定义的,所以如果 希望 绘制水平线,应该使用适当的 CSS。
-
The
<hr>
HTML element represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section. -
Historically, this has been presented as a horizontal rule or line. While it may still be displayed as a horizontal rule in visual browsers, this element is now defined in semantic terms, rather than presentational terms, so if you wish to draw a horizontal line, you should do so using appropriate CSS.
html (根元素、顶级元素、仅一个)
-
<html>
html元素 表示 html 文档的 根元素(顶级元素),因此它也被称为 根元素。所有其他元素 必须是该元素的后代。 -
The
<html>
HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element.
I
i(非普通文本:习惯用语、技术术语、分类名称)
-
<i>
HTML元素表示 由于某种原因(如 习惯用语、专业术语、分类名称等)而 与普通文本 相区分的文本范围。从历史上看,这些都是使用 斜体字表示的,这是该元素<i>
命名的 原始来源。 -
The
<i>
HTML element represents a range of text that is set off from the normal text for some reason, such as idiomatic text, technical terms, taxonomical designations, among others. Historically, these have been presented using italicized type, which is the original source of the<i>
naming of this element.
iframe (页面嵌入、浏览环境)
<iframe>
HTML元素表示 一个嵌套的浏览环境,将另一个 HTML 页面 嵌入 到 当前页面中。- 每个嵌入式的浏览环境 都有自己的 会话历史记录和文档。嵌入了其他浏览环境的浏览环境 称为父浏览环境。最顶层的浏览环境(没有父环境)通常是浏览器窗口,由
window
对象表示。 - 因为每个浏览环境 都是一个完整的文档环境,所以页面中的每个
<iframe>
都需要 增加内存和其他计算资源。虽然理论上 您可以使用尽可能多的<iframe>
s,,但要检查 性能问题。- 注:,“browsing context”(浏览环境 )是一个表示 网页或文档在浏览器中 展示环境的术语。它定义了 网页的导航和 脚本执行环境。简单来说,每个打开的 浏览器标签页或窗口 都可以被视为一个 独立的浏览环境。
- The
<iframe>
HTML element represents a nested browsing context , embedding another HTML page into the current one. - Each embedded browsing context has its own session history and document . The browsing context that embeds the others is called the parent browsing context. The topmost browsing context — the one with no parent — is usually the browser window, represented by the Window object.
- Because each browsing context is a complete document environment, every
<iframe>
in a page requires increased memory and other computing resources. While theoretically you can use as many<iframe>
s as you like, check for performance problems.
img (图像、图像路径)
<img>
HTML元素 将图像嵌入 到文档中。src
属性是必需的,它包含您想要嵌入的 图像的路径。alt
属性包含 图像的 文本描述,这不是强制性的,但对于可访问性 非常有用——屏幕阅读器 将此描述读出来 给用户听,以便他们知道图像的含义。如果 由于某些原因 无法加载图像,则 Alt 文本也会显示 在页面上:例如,网络错误,内容阻塞 或链接失效。
- 还有许多其他属性 可以实现各种目的:
- 用于安全和隐私的
Referrer
/CORS
控制:请参阅交叉源和refererpolicy
。 - 使用宽度
width
和高度height
来设置图像的固有大小,允许它在加载之前占用空间,以减轻内容布局的变化。 - 响应式图像提示的大小和 srcset(另见
<picture>
元素和我们的响应式图像教程)。
- 用于安全和隐私的
- The
<img>
HTML element embeds an image into the document.- The
src
attribute is required, and contains the path to the image you want to embed. - The
alt
attribute holds a text description of the image, which isn’t mandatory but is incredibly useful for accessibility — screen readers read this description out to their users so they know what the image means. Alt text is also displayed on the page if the image can’t be loaded for some reason: for example, network errors, content blocking, or linkrot.
- The
- There are many other attributes to achieve various purposes:
Referrer /CORS
control for security and privacy: see crossorigin and referrerpolicy.- Use both
width
andheight
to set the intrinsic size of the image, allowing it to take up space before it loads, to mitigate content layout shifts. - Responsive image hints with
sizes
andsrcset
(see also the<picture>
element and our Responsive images tutorial).
input(用户数据、控件)
<input>
HTML元素用于 为基于 web 的表单 创建交互式控件,以便接受 来自 用户的数据;可以使用各种类型的输入数据 和 控件小部件,具体取决于设备和用户代理。<input>
元素是所有 HTML 中最强大、最复杂的元素之一,因为它包含了 大量的输入类型和属性组合。- The
<input>
HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent . The<input>
element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.
ins (已添加文本)
- HTML元素表示 已添加到文档中的一批文本。可以使用
<del>
元素类似地表示 已从文档中 删除的文本。 - The
<ins>
HTML element represents a range of text that has been added to a document. You can use the<del>
element to similarly represent a range of text that has been deleted from the document.
K
kbd (文本输入设备:键盘、语音)
<kbd>
HTML元素表示 一段内联文本,表示 来自键盘、语音输入或 任何其他 文本输入设备的 用户文本输入。按照惯例,用户代理 默认使用 其默认的等宽字体 呈现<kbd>
元素的内容,尽管 HTML 标准 没有强制要求这样做。<kbd>
可以与<samp>
(样本输出)元素 以各种组合嵌套,以根据视觉提示 表示各种形式的输入或输出。- The
<kbd>
HTML element represents a span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device. By convention, the user agent defaults to rendering the contents of a<kbd>
element using its default monospace font, although this is not mandated by the HTML standard.
<kbd>
may be nested in various combinations with the<samp>
(Sample Output) element to represent various forms of input or output based on visual cues.
L
label (说明)
<label>
HTML元素 表示用户界面中 某项的说明。- 将
<label>
与<input>
元素关联起来 有以下几个主要优点: - 标签文本 不仅在视觉上 与其相应的文本输入相关联;它在编程上 也与它相关联。
- 这意味着,例如,当用户专注于表单输入时,屏幕阅读器 将读出标签,使辅助技术用户 更容易理解 应该输入哪些数据。
- 您可以单击关联的标签 来聚焦/激活输入,以及输入本身。这种增加的点击面积 为任何试图激活输入的人 提供了一个优势,包括那些使用触摸屏设备的人。
- 要将
<label>
与<input>
元素关联起来- 需要为
<input>
赋予一个id
属性。然后,<label>
需要一个for
属性,其值与输入的id
相同。 - 或者,你可以直接在
<label>
中嵌套<input>
,在这种情况下,不需要for
和id
属性,因为关联是 隐式的:
- 需要为
<label>Do you like peas?
<input type="checkbox" name="peas">
</label>
-
其他用法说明:
- 标签所标记的表单控件 称为
label
元素的 标签控件。一个输入 可以与多个标签 相关联。 - 当单击或点击
<label>
并将其 与表单控件关联时,也会为关联控件引发 所产生的单击事件。
- 标签所标记的表单控件 称为
-
The
<label>
HTML element represents a caption for an item in a user interface. -
Associating a
<label>
with an<input>
element offers some major advantages: -
The label text is not only visually associated with its corresponding text input; it is programmatically associated with it too.
- This means that, for example, a screen reader will read out the label when the user is focused on the form input, making it easier for an assistive technology user to understand what data should be entered.
- You can click the associated label to focus/activate the input, as well as the input itself. This increased hit area provides an advantage to anyone trying to activate the input, including those using a touch-screen device.
-
To associate the
<label>
with an<input>
element,- you need to give the
<input>
anid
attribute. The<label>
then needs afor
attribute whose value is the same as the input’s id. - Alternatively, you can nest the
<input>
directly inside the<label>
, in which case the for and id attributes are not needed because the association is implicit:
- you need to give the
<label>Do you like peas?
<input type="checkbox" name="peas">
</label>
- Other usage notes:
- The form control that the label is labeling is called the labeled control of the label element. One input can be associated with multiple labels.
When a<label>
is clicked or tapped and it is associated with a form control, the resulting click event is also raised for the associated control.
li (列表项)
<li>
HTML元素用于表示 列表中的项。它必须包含在父元素中:有序列表(<ol>
)、无序列表(<ul>
)或菜单(<menu>
)。- 在菜单和无序列表中,列表项 通常使用 项目符号黑圆点 显示。在有序列表中,它们通常在左侧 显示 一个升序计数器,例如 数字或字母。
- The
<li>
HTML element is used to represent an item in a list. It must be contained in a parent element: an ordered list(<ol>
), an unordered list (<ul>
), or a menu (<menu>
). - In menus and unordered lists, list items are usually displayed using bullet points. In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.
link(资源关系、链接)
<link>
HTML元素指定 当前文档 和 外部资源之间的关系。此元素最常用于 样式表 的链接,但也用于 建立站点图标(包括“favicon”样式图标 以及主屏幕和移动设备上的 应用程序图标)。- 要链接 外部样式表,你需要在
<head>
中加入一个<link>
元素,如下所示:
<link href="main.css" rel="stylesheet">
-
这个简单的示例 在一个
href
属性中 提供了 样式表的路径,和一个值为stylesheet
的rel
属性 。rel
代表“关系”,可能是<link>
元素的关键特性之一——该值表示 被链接的项 与包含它的文档之间的关系。正如您会 从链接类型参考中 看到的,有许多不同类型的关系。
-
The
<link>
HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets , but is also used to establish site icons (both “favicon” style icons and icons for the home screen and apps on mobile devices) among other things.
To link an external stylesheet, you’d include a<link>
element inside your<head>
like this:
<link href="main.css" rel="stylesheet">
-
This simple example provides the path to the stylesheet inside an
href
attribute, and arel
attribute with a value ofstylesheet
.- The
rel
stands for “relationship”, and is probably one of the key features of the<link>
element — the value denotes how the item being linked to is related to the containing document. As you’ll see from our Link types reference, there are many different kinds of relationship.
- The
-
你还会遇到 其他一些常见的类型。例如,网站图标的链接:
<link rel="icon" href="favicon.ico">
- 还有 许多其他图标的
rel
值,主要用于指示 在各种移动平台上 使用的特殊图标类型,例如:
<link rel="apple-touch-icon-precomposed" sizes="114x114"
href="apple-icon-114.png" type="image/png">
sizes
属性指示 图标的大小,而type
包含所链接资源的 MIME 类型。这些提供了 有用的提示,允许浏览器 选择最合适的可用图标。- 您还可以在媒体属性
media
中 提供媒体类型或查询;只有当媒体条件为真时,才会加载此资源。例如:
<link href="print.css" rel="stylesheet" media="print">
<link href="mobile.css" rel="stylesheet" media="screen and (max-width: 600px)">
- There are a number of other common types you’ll come across. For example, a link to the site’s favicon:
<link rel="icon" href="favicon.ico">
- There are a number of other icon
rel
values, mainly used to indicate special icon types for use on various mobile platforms, e.g.:
<link rel="apple-touch-icon-precomposed" sizes="114x114"
href="apple-icon-114.png" type="image/png">
- The
sizes
attribute indicates the icon size, while the type contains the MIME type of the resource being linked. These provide useful hints to allow the browser to choose the most appropriate icon available. - You can also provide a media type or query inside a
media
attribute; this resource will then only be loaded if the media condition is true. For example:
<link href="print.css" rel="stylesheet" media="print">
<link href="mobile.css" rel="stylesheet" media="screen and (max-width: 600px)">
<link>
元素还添加了一些有趣的新性能和安全特性。举个例子:
<link rel="preload" href="myFont.woff2" as="font"
type="font/woff2" crossorigin="anonymous">
- Some interesting new performance and security features have been added to the element too. Take this example:
<link rel="preload" href="myFont.woff2" as="font"
type="font/woff2" crossorigin="anonymous">
-
A rel value of preload indicates that the browser should preload this resource (see Preloading content with rel=“preload” for more details), with the as attribute indicating the specific class of content being fetched. The crossorigin attribute indicates whether the resource should be fetched with a CORS request.
-
rel
的值preload
表示浏览器应该 预加载该资源(请参阅使用rel="preload"预加载内容 了解更多细节),而as
属性表示 所获取的内容的特定类。交叉源属性crossorigin
指示是否应该使用CORS
请求获取资源。 -
其他用法说明:
<link>
元素既可以出现在<head>
元素中,也可以出现在<body>
元素中,这取决于它的链接类型是否为body-ok
。- 例如,样式表 链接类型 是
body-ok
,因此<link rel="stylesheet">
允许在body
中使用。然而,这并不是一个好的做法;将<link>
元素从body
内容中分离出来更有意义,将它们放在<head>
中。 - 当使用
<link>
为站点建立favicon
时,如果站点使用了CSP
(Content Security Policy)来增强其安全性,则该策略适用于该favicon
。如果遇到图标未加载的问题,请验证Content-Security-Policy
头文件的img-src
指令没有阻止对它的访问。 - HTML 和 XHTML 规范为
<link>
元素定义了 事件处理程序,但不清楚如何使用它们。 - 在XHTML 1.0中,像
<link>
这样的空元素 需要一个尾斜杠:<link />
。 - WebTV 支持使用
next
值来预加载 下一个页面。
-
Other usage notes:
- A
<link>
element can occur either in the<head>
or<body>
element, depending on whether it has a link type that isbody-ok
. For example, the stylesheet link type isbody-ok
, and therefore<link rel="stylesheet">
is permitted in the body. However, this isn’t a good practice to follow; it makes more sense to separate your<link>
elements from your body content, putting them in the<head>
. - When using
<link>
to establish a favicon for a site, and your site uses a Content Security Policy (CSP
) to enhance its security, the policy applies to the favicon. If you encounter problems with the favicon not loading, verify that theContent-Security-Policy
header’s img-src directive is not preventing access to it. - The HTML and XHTML specifications define event handlers for the
<link>
element, but it is unclear how they would be used.
Under XHTML 1.0, empty elements such as<link>
require a trailing slash:<link />
. - WebTV supports the use of the value
next
for rel to preload the next page in a document series.
- A
M
meta (元数据)
<meta>
HTML元素表示 其他 HTML 元相关元素(如<base>
、<link>
、<script>
、<style>
或<title>
)无法表示的 元数据。<meta>
元素提供的 元数据类型 可以是以下类型之一:- 如果设置了
name
属性,<meta>
元素将提供 应用于整个页面的 文档级 元数据。 - 如果设置了
HTTP -equiv
属性,则<meta>
元素是一个pragma
指令,提供与 同名 HTTP 头信息 相同的信息。 - 如果设置了
charset
属性,则<meta>
元素是一个 字符集声明,给出了对文档 进行编码的 字符编码。 - 如果设置了
itemprop
属性,则元素提供 用户定义的元数据。
- 如果设置了
- The
<meta>
HTML element represents metadata that cannot be represented by other HTML meta-related elements, like<base>
,<link>
,<script>
,<style>
or<title>
. - The type of metadata provided by the
<meta>
element can be one of the following:- If the
name
attribute is set, the<meta>
element provides document-level metadata, applying to the whole page. - If the
http-equiv
attribute is set, the<meta>
element is a pragma directive, providing information equivalent to what can be given by a similarly-named HTTP header. - If the
charset
attribute is set, the<meta>
element is a charset declaration, giving the character encoding in which the document is encoded. - If the
itemprop
attribute is set, the<meta>
element provides user-defined metadata.
- If the
O
ol (有序列表)
<ol>
HTML元素表示一个有序的项目列表——通常呈现为 一个编号的列表。- The
<ol>
HTML element represents an ordered list of items — typically rendered as a numbered list.
P
p (一个段落、内容分组)
-
<p>
HTML元素 表示 一个段落。在视觉媒体中,段落通常被表示为 用 “空白行” 和(或)“ 第一行缩进” 与相邻的文本块分隔的 文本块,但 HTML 段落可以是 相关内容的 任何结构化分组,例如 图像或表单字段。 -
段落是 块级元素,如果在结束
</p>
标记之前 解析了另一个块级元素,段落将 自动关闭。参见下面的“省略标签”。 -
The
<p>
HTML element represents a paragraph. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields. -
Paragraphs are block-level elements , and notably will automatically close if another block-level element is parsed before the closing
</p>
tag. See “Tag omission” below.
pre (预格式化、原始格式)
<pre>
HTML元素表示 预格式化的文本,该文本将 完全按照 HTML 文件中 写入的方式呈现。文本通常使用 非比例或“等宽”字体呈现。此元素中的空白 按写入方式显示。- The
<pre>
HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or "monospaced , font. Whitespace inside this element is displayed as written.
q (短的、内联引用、引号)
<q>
HTML元素表示 所包含的文本是一个 简短的内联引用。大多数现代浏览器 通过在文本周围加上引号 来实现这一点。此元素用于 不需要分段的 简短引用;对于长引号,使用<blockquote>
元素。- 使用注意:大多数现代浏览器 会自动 在
<q>
元素内的文本周围 添加引号。在较旧的浏览器中,可能需要样式规则 来添加引号。 - The
<q>
HTML element indicates that the enclosed text is a short inline quotation. Most modern browsers implement this by surrounding the text in quotation marks. This element is intended for short quotations that don’t require paragraph breaks; for long quotations use the<blockquote>
element. - Usage note: Most modern browsers will automatically add quotation marks around text inside a
<q>
element. A style rule may be needed to add quotation marks in older browsers.
S
samp (程序输出 示例、样本)
<samp>
HTML元素用于 将内联文本括起来,这些文本表示 计算机程序的示例(或引用)输出。它的内容 通常使用 浏览器默认的等宽字体(如Courier 或 Lucida Console)来呈现。- The
<samp>
HTML element is used to enclose inline text which represents sample (or quoted) output from a computer program. Its contents are typically rendered using the browser’s default monospaced font (such as Courier or Lucida Console).
script (嵌入、引用、 js代码)
<script>
HTML元素用于 嵌入可执行代码或数据;这通常用于 嵌入或引用 JavaScript 代码。<script>
元素还可以与其他语言一起使用,例如WebGL的GLSL 着色器编程语言 和 JSON。- The
<script>
HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The<script>
element can also be used with other languages, such as WebGL 's GLSL shader programming language and JSON .
small (旁注、小字体、版权、法律文本)
<small>
HTML元素表示 旁注和小字体,如 版权和法律文本,独立于其样式表示。默认情况下,它会将其中的文本渲染 小一个字体大小,例如从small
到x-small
。- The
<small>
HTML element represents side-comments and small print, like copyright and legal text, independent of its styled presentation. By default, it renders text within it one font-size smaller, such as fromsmall
tox-small
.
span (内联容器、分组、样式化)
-
<span>
HTML元素是 短语内容(短句内容) 的 通用内联容器,它本身 并不表示任何东西。它可以用于 对元素进行分组,以达到 样式化 的目的(使用class
或id
属性),或者因为它们共享属性值,比如lang
。只有在没有其他 合适的语义元素时 才应该使用它。<span>
与<div>
元素非常相似,但是<div>
是块级元素,而<span>
是内联元素。 -
The
<span>
HTML element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using theclass
orid
attributes), or because they share attribute values, such aslang
. It should be used only when no other semantic element is appropriate.<span>
is very much like a<div>
element, but<div>
is a block-level element whereas a<span>
is an inline element .
strong (非常重要、严肃、紧迫)
<strong>
HTML元素 表示其内容具有 很强的重要性、严肃性或紧迫性。浏览器通常 以粗体 显示内容。- The
<strong>
HTML element indicates that its contents have strong importance, seriousness, or urgency. Browsers typically render the contents in bold type.
style(样式信息)
-
<style>
HTM L元素包含 文档或文档的一部分的 样式信息。它包含 CSS,应用于包含<style>
元素的 文档的内容。 -
<style>
元素必须包含 在文档的<head>
中。一般来说,最好 将样式放在外部样式表中,并使用<link>
元素应用它们。 -
如果在文档中 包含多个
<style>
和<link>
元素,它们将 按照它们在文档中包含的顺序 应用于DOM ——确保以正确的顺序 包含它们,以避免意外的级联问题。 -
以 与
<link>
元素 相同的方式,<style>
元素可以包含 包含媒体查询的 媒体属性,允许您 根据媒体特性(如视口宽度)选择性地 将内部样式表 应用于文档。 -
The
<style>
HTML element contains style information for a document, or part of a document. It contains CSS, which is applied to the contents of the document containing the<style>
element. -
The
<style>
element must be included inside the<head>
of the document. In general, it is better to put your styles in external stylesheets and apply them using<link>
elements. -
If you include multiple
<style>
and<link>
elements in your document, they will be applied to the DOM in the order they are included in the document — make sure you include them in the correct order, to avoid unexpected cascade issues. -
In the same manner as
<link>
elements,<style>
elements can include media attributes that contain media queries , allowing you to selectively apply internal stylesheets to your document depending on media features such as viewport width.
sub(下标、基线低、文本小)
<sub>
HTML元素指定内联文本,该文本仅出于排版原因 应显示为下标。下标通常以 较低的基线 和 较小的文本 呈现。- The
<sub>
HTML element specifies inline text which should be displayed as subscript for solely typographical reasons. Subscripts are typically rendered with a lowered baseline using smaller text.
sup(上标、基线高、文本小)
<sup>
HTML元素 指定内联文本,仅出于排版原因 将其显示为 上标。上标通常使用 较小的文本 以凸起的基线 呈现。- The
<sup>
HTML element specifies inline text which is to be displayed as superscript for solely typographical reasons. Superscripts are usually rendered with a raised baseline using smaller text.
T
table(表格数据、二维表格)
<table>
HTML元素表示 表格数据 — 即,在 包含数据的 单元格的 行和列 组成的 二维表格中 显示的信息。- The
<table>
HTML element represents tabular data — that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.
td (数据单元格)
<td>
HTML元素定义了 一个包含数据的 表格单元格。它参与表模型。- The
<td>
HTML element defines a cell of a table that contains data. It participates in the table model.
th (一组单元格的标题)
<th>
HTML元素 将单元格定义为 一组表格单元格的 标题。该组的确切性质由scope
和headers
属性定义。- The
<th>
HTML element defines a cell as header of a group of table cells. The exact nature of this group is defined by thescope
andheaders
attributes.
title(文档标题、标题栏、选项卡)
<title>
HTML元素定义了 显示在 浏览器标题栏 或 页面选项卡中 的文档标题。它只包含文本;元素中的标签 将被忽略。- The
<title>
HTML element defines the document’s title that is shown in a browser 's title bar or a page’s tab. It only contains text; tags within the element are ignored.
tr (一行单元格)
-
<tr>
HTML元素 在表格中定义 一行单元格。然后可以使用<td>
(数据单元格)和<th>
(标题单元格)元素的混合 来建立行单元格。 -
为了提供对单元格如何适合(或跨)列的额外控制,
<th>
和<td>
都支持colspan
属性,该属性允许您指定 单元格应该有多少列宽,默认值为1。类似地,您可以在单元格上使用rowspan
属性来指示它们 应该跨越多个表行。 -
The
<tr>
HTML element defines a row of cells in a table. The row’s cells can then be established using a mix of<td>
(data cell) and<th>
(header cell) elements. -
To provide additional control over how cells fit into (or span across) columns, both
<th>
and<td>
support thecolspan
attribute, which lets you specify how many columns wide the cell should be, with the default being 1. Similarly, you can use therowspan
attribute on cells to indicate they should span more than one table row.
U
ul (无序列表)
<ul>
HTML元素表示 一个无序的项目列表,通常呈现为 黑圆点的列表。- The
<ul>
HTML element represents an unordered list of items, typically rendered as a bulleted list.
V
var (变量名称、数学、编程)
<var>
HTML元素表示 数学表达式或编程语境中 变量的名称。它通常使用 当前字体的斜体版本 来显示,尽管这种行为 依赖于浏览器。- The
<var>
HTML element represents the name of a variable in a mathematical expression or a programming context. It’s typically presented using an italicized version of the current typeface, although that behavior is browser-dependent.