草案
此页面不完整。

rel attribute defines the relationship between a linked resource and the current document. Valid on <link> , <a> , <area> ,和 <form> , the supported values depend on the element on which the attribute is found.

The type of relationships is given by the value of the rel attribute, which, if present, must have a value that is an unordered set of unique space-separated keywords, which are listed in the following table. Every keyword within a space-separated value should be unique within that value.

Values for the rel attribute, and the elements for which each is relevant
rel 描述 <link> <a> and <area> <form>
alternate Alternate representations of the current document. 链接 链接 Not allowed
作者 Author of the current document or article. 链接 链接 Not allowed
bookmark Permalink for the nearest ancestor section. Not allowed 链接 Not allowed
canonical Preferred URL for the current document. 链接 Not allowed Not allowed
dns-prefetch Tells the browser to preemptively perform DNS resolution for the target resource's origin External Resource Not allowed Not allowed
external The referenced document is not part of the same site as the current document. Not allowed Annotation Annotation
help Link to context-sensitive help. 链接 链接 链接
icon An icon representing the current document. External Resource Not allowed Not allowed
license Indicates that the main content of the current document is covered by the copyright license described by the referenced document. 链接 链接 链接
manifest Web app manifest 链接 Not allowed Not allowed
modulepreload Tells to browser to preemptively fetch the script and store it in the document's module map for later evaluation. Optionally, the module's dependencies can be fetched as well. External Resource Not allowed Not allowed
next Indicates that the current document is a part of a series and that the next document in the series is the referenced document. 链接 链接 链接
nofollow Indicates that the current document's original author or publisher does not endorse the referenced document. Not allowed Annotation Annotation
noopener Creates a top-level browsing context that is not an auxiliary browsing context if the hyperlink would create either of those, to begin with (i.e., has an appropriate target attribute value). Not allowed Annotation Annotation
noreferrer No Referer header will be included. Additionally, has the same effect as noopener . Not allowed Annotation Annotation
opener Creates an auxiliary browsing context if the hyperlink would otherwise create a top-level browsing context that is not an auxiliary browsing context (i.e., has " _blank " as target attribute value). Not allowed Annotation Annotation
pingback Gives the address of the pingback server that handles pingbacks to the current document. External Resource Not allowed Not allowed
preconnect Specifies that the user agent should preemptively connect to the target resource's origin. External Resource Not allowed Not allowed
prefetch Specifies that the user agent should preemptively fetch and cache the target resource as it is likely to be required for a followup navigation. External Resource Not allowed Not allowed
preload Specifies that the user agent must preemptively fetch and cache the target resource for current navigation according to the potential destination given by the as attribute (and the priority associated with the corresponding destination). External Resource Not allowed Not allowed
prerender Specifies that the user agent should preemptively fetch the target resource and process it in a way that helps deliver a faster response in the future. External Resource Not allowed Not allowed
prev Indicates that the current document is a part of a series and that the previous document in the series is the referenced document. 链接 链接 链接
search Gives a link to a resource that can be used to search through the current document and its related pages. 链接 链接 链接
样式表 Imports a style sheet. External Resource Not allowed Not allowed
tag Gives a tag (identified by the given address) that applies to the current document. Not allowed 链接 Not allowed

rel attribute is relevant to the <link> , <a> , <area> ,和 <form> elements, but some values only relevant to a subset of those elements. Like all HTML keyword attribute values, these values are case-insenstive.

rel attribute has no default value. If the attribute is omitted or if none of the values in the attribute are supported, then the document has no particular relationship with the destination resource other than there being a hyperlink between the two. In this case, on <link> and <form> , if the rel attribute is absent, has no keywords, or if not one or more of the space-separated keywords above, then the element does not create any links. <a> and <area> will still created links, but without a defined relationship.

Like all HTML keyword attribute values, these values are case-insensitive.

If there are multiple <link rel="icon"> s, the browser uses their media 属性, type and sizes attributes to select the most appropriate icon. If several icons are equally appropriate, the last one is used. If the most appropriate icon is later found to be inappropriate, for example, because it uses an unsupported format, the browser proceeds to the next-most appropriate, and so on.

注意: Apple's iOS does not use this link type, nor the sizes attribute, like others mobile browsers do, to select a webpage icon for Web Clip or a start-up placeholder. Instead, it uses the non-standard apple-touch-icon and apple-touch-startup-image 分别。

shortcut link type is often seen before icon , but this link type is non-conforming, ignored and web authors must not use it anymore .

alternate
Indicates an alternate representation of the current document. Valid for link, a, and area, the meaning depends on the values of the other attributes.
  • With the 样式表 keyword on a <link> , it creates an alternate stylesheet.
    <!-- a persistent style sheet -->
    <link rel="stylesheet" href="default.css">
    <!-- alternate style sheets -->
    <link rel="alternate stylesheet" href="highcontrast.css" title="High contrast">
    									
  • With an hreflang attribute that differs from the document language, it indicates a translation.
  • With the type attribute, it indicates that the referenced document is the same content in a different format. For example, with type="application/rss+xml" it creates a hyperlink referencing a syndication feed.
    <link rel="alternate" type="application/atom+xml" href="posts.xml" title="Blog">
    									
  • 两者 hreflang and type attributes specify links to versions of the document in an alternative format and language, intended for other media:
    <link rel=alternate href="/fr/html/print" hreflang=fr type=text/html media=print title="French HTML (for printing)">
    <link rel=alternate href="/fr/pdf" hreflang=fr type=application/pdf title="French PDF">
    									
作者
Indicates the author of the current document or article. Relevant for <link> , <a> ,和 <area> elements, the 作者 keyword creates a hyperlink. With <a> and <area> , it indicates the linked document (or mailto: ) provides information about the author of the nearest <article> ancestor if there is one, otherwise the entire document. For <link> , it represents the author of the entire document.

Note: The obsolete rev="made" is treated as rel="alternate"

bookmark
Relevant as the rel attribute value for the <a> and <area> elements, the bookmark provides a permalink for ancestor section, which is the nearest ancestor <article> or <section> , if there is at least one, otherwise, the nearest heading sibling or ancestor descendant, to the next..
canonical
Valid for <link> , it defines the preferred URL for the current document, which is useful for search engines.
dns-prefetch
Relevant for the <link> element both in the <body> and <head> , it tells the browser to preemptively perform DNS resolution for the target resource's origin. Useful for resources the user will likely need, it helps reduce latency and thereby improves performance when the user does access the resources as the browser preemptively performed DNS resolution for the origin of the specified resource. See dns-prefetch described in resource hints .
external
Relevant to <form> , <a> ,和 <area> , it indicates the referenced document is not part of the current site. This can be used with attribute selectors to style external links in a way that indicates to the user that they will be leaving the current site.
help
Relevant to <form> , <link> , <a> ,和 <area> help keyword indicates that the linked to content provides context-sensitive help, providing information for the parent of the element defining the hyperlink, and its children. When used within <link> , the help is for the whole document. When included with <a> and <area> and supported, the default cursor 将是 help 而不是 pointer .
icon

Valid with <link> , the linked resource represents the icon, a resource for representing the page in the user interface, for the current document.

The most common use for the icon value is the favicon:

<link rel="icon" href="favicon.ico">
						

If there are multiple <link rel="icon"> s, the browser uses their media 属性, type ,和 sizes attributes to select the most appropriate icon. If several icons are equally appropriate, the last one is used. If the most appropriate icon is later found to be inappropriate, for example because it uses an unsupported format, the browser proceeds to the next-most appropriate, and so on.

Prior to Firefox 83 the crossorigin attribute was not supported for rel="icon" there is also an open issue for Chrome .

注意: Apple's iOS does not use this link type, nor the sizes attribute, like others mobile browsers do, to select a webpage icon for Web Clip or a start-up placeholder. Instead it uses the non-standard apple-touch-icon and apple-touch-startup-image 分别。

shortcut link type is often seen before icon , but this link type is non-conforming, ignored and web authors must not use it anymore .

license

Valid on the <a> , <area> , <form> , <link> elements, the license value indicates that the hyperlink leads to a document describing the licensing information; that the main content of the current document is covered by the copyright license described by the referenced document. If not inside the <head> element, the standard doesn't distinguish between a hyperlink applying to a specific part of the document or to the document as a whole. Only the data on the page can indicate this.

<link rel="license" href="#license">
						

注意: Although recognized, the synonym copyright is incorrect and must be avoided.

manifest
Web app manifest . Requires the use of the CORS protocol for cross-origin fetching.
modulepreload
Useful for improved performance, and relevant to the <link> anywhere in the document, setting rel="modulepreload" tells the browser to preemptively fetch the script (and dependencies) and store it in the document's module map for later evaluation. modulepreload links can ensure network fetching is done with the module ready (but not evaluated) in the module map before it is necessarily needed. See also link types: modulepreload .
next
Relevant to <form> , <link> , <a> ,和 <area> next values indicates that the current document is a part of a series, and that the next document in the series is the referenced document. When included in a <link> , browsers may assume that document will be fetched next, and treat it as a resource hint.
nofollow
Relevant to <form> , <a> ,和 <area> nofollow keyword tells search engine spiders to ignore the link relationship. The nofollow relationship may indicate the current document's owner does not endorse the referenced document. It is often included by Search Engine Optimizers pretending their link farms are not spam pages.
noopener
Relevant to <form> , <a> ,和 <area> , creates a top-level browsing context that is not an auxiliary browsing context if the hyperlink would create either of those to begin with (i.e., has an appropriate target attribute value). In other words, it makes the link behave as if window.opener were null and target ="_parent" were set.

This is the opposite of opener .
noreferrer
Relevant to <form> , <a> ,和 <area> , including this value makes the referrer unknown (no Referer header will be included), and opens the creates a top-level browsing context, as if noopener were also set.
opener
Creates an auxiliary browsing context if the hyperlink would otherwise create a top-level browsing context that is not anauxiliary browsing context (i.e., has " _blank " as target attribute value). Effectively, the opposite of noopener .
pingback

Gives the address of the pingback server that handles pingbacks to the current document.

preconnect

Specifies that the user agent should preemptively connect to the target resource's origin.

prefetch

Specifies that the user agent should preemptively fetch and cache the target resource as it is likely to be required for a followup navigation.

preload
Specifies that the user agent must preemptively fetch and cache the target resource for current navigation according to the potential destination given by the as attribute (and the priority associated with the corresponding destination).
prerender

Specifies that the user agent should preemptively fetch the target resource and process it in a way that helps deliver a faster response in the future.

prev

类似于 next keyword, relevant to <form> , <link> , <a> ,和 <area> prev values indicates that the current document is a part of a series, and that the link references a previous document in the series is the referenced document.

Note: The synonym 上一 is incorrect and should not be used.

search

Relevant to <form> , <link> , <a> ,和 <area> elements, the search keywords indicates that the hyperlink references a document whose interface is specially designed for searching in the current document, site, and related resources, providing a link to a resource that can be used to search.

type attribute is set to application/opensearchdescription+xml the resource is an OpenSearch plugin that can be easily added to the interface of some browsers like Firefox or Internet Explorer.

样式表

Valid for the <link> element, it imports an external resource to be used as a stylesheet. The type attribute is not needed as it's a text/css stylesheet, as that is the default value. If it's not a stylesheet of type text/css it is best to declare the type.

While this attribute defines the link as being a stylesheet, the interaction with other attributes and other key terms within the rel value impact whether the stylesheet is downloaded and/or used.

当用于 alternate keyword, it defines an alternative style sheet. In this case, include a non-empty title .

The external stylesheet will not be used or even downloaded if the media does not match the value of the media 属性。

Requires the use of the CORS protocol for cross-origin fetching.

tag
Valid for the <a> ,和 <area> elements, it gives a tag (identified by the given address) that applies to the current document. The tag value denotes that the link refers to a document describing a tag applying to the document on which it is located. This link type is not meant for tags within a tag cloud, as those tags apply to a group of pages, whereas the tag value of the rel attribute is for a single document.

Non-standard values

apple-touch-icon-precomposed
 <!-- third-generation iPad with high-resolution Retina display: -->
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/favicon144.e7e21ca263ca.png">
  <!-- iPhone with high-resolution Retina display: -->
  <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/favicon114.d526f38b09c5.png">
  <!-- first- and second-generation iPad: -->
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/favicon72.cc65d1d762a0.png">
  <!-- non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
  <link rel="apple-touch-icon-precomposed" href="/static/img/favicon57.de33179910ae.png">
  <!-- basic favicon -->
  <link rel="shortcut icon" href="/static/img/favicon32.7f3da72dcea1.png">
							

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "html.elements.attributes.rel" (depth: 1) to the MDN 兼容性数据存储库 .

规范

规范 状态 注释
HTML 实时标准
The definition of 'rel attribute' in that specification.
实时标准 添加 opener . Made noopener default  for target="_blank" .
HTML5
The definition of 'rel attribute' in that specification.
推荐 添加 tag , search , prefetch , noreferrer , nofollow , icon ,和 作者 .
重命名 copyright to license .
移除 start , chapter , section , subsection ,和 appendix
Preload
The definition of 'preload' in that specification.
候选推荐 添加 preload .
Resource Hints
The definition of 'preconnect' in that specification.
工作草案 添加 dns-prefetch , preconnect ,和 prerender 值。
HTML 4.01 Specification
The definition of 'link types' in that specification.
推荐 添加 alternate , 样式表 , start , chapter , section , subsection , appendix ,和 bookmark .
重命名 上一 to prev .
移除 top ,和 search .
未知
The definition of '<link>' in that specification.
未知 (Obsolete) 添加 top , contents , index , glossary , copyright , next , 上一 , help ,和 search .
RFC 1866: HTML 2.0 未知 (Obsolete) 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
rel Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
Alternative stylesheets. Chrome 不支持 1 — 48 Edge ? Firefox 完整支持 3 IE 完整支持 8 Opera 完整支持 Yes Safari ? WebView Android ? Chrome Android ? Firefox Android 完整支持 4 Opera Android ? Safari iOS ? Samsung Internet Android ?
dns-prefetch 实验性 Chrome 完整支持 46 Edge 完整支持 ≤79 Firefox 完整支持 3 IE ? Opera 完整支持 33 Safari ? WebView Android 完整支持 46 Chrome Android 完整支持 Yes Firefox Android 完整支持 4 Opera Android ? Safari iOS ? Samsung Internet Android 完整支持 Yes
icon Chrome 完整支持 4 注意事项
完整支持 4 注意事项
注意事项 If both ICO and PNG are available, will use ICO over PNG if ICO has better matching sizes set. (Per caniuse.com.)
Edge 完整支持 12 注意事项
完整支持 12 注意事项
注意事项 In version 79 and later (Blink-based Edge), if both ICO and PNG are available, will use ICO over PNG if ICO has better matching sizes set. (Per caniuse.com.)
Firefox 完整支持 2 IE 完整支持 11 Opera 完整支持 9 注意事项
完整支持 9 注意事项
注意事项 In version 15 and later (Blink-based Opera), if both ICO and PNG are available, will use ICO over PNG if ICO has better matching sizes set. (Per caniuse.com.)
Safari 完整支持 3.1 注意事项
完整支持 3.1 注意事项
注意事项 If both ICO and PNG are available, will ALWAYS use ICO file, regardless of sizes set. (Per caniuse.com.)
WebView Android 完整支持 38 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 不支持 No Safari iOS 不支持 No 注意事项
不支持 No 注意事项
注意事项 Does not use favicons at all (but may have alternative for bookmarks, etc.). (Per caniuse.com.)
Samsung Internet Android 完整支持 4.0
manifest 实验性 非标 Chrome 不支持 No Edge 不支持 No Firefox ? IE ? Opera 不支持 No Safari ? WebView Android 完整支持 39 Chrome Android 完整支持 39 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 完整支持 4.0
modulepreload 实验性 Chrome 完整支持 66 Edge 完整支持 ≤79 Firefox ? IE ? Opera 完整支持 53 Safari ? WebView Android 完整支持 66 Chrome Android 完整支持 66 Firefox Android ? Opera Android 完整支持 47 Safari iOS ? Samsung Internet Android 完整支持 9.0
preconnect 实验性 Chrome 完整支持 46 Edge 完整支持 79 Firefox 完整支持 39 注意事项
完整支持 39 注意事项
注意事项 Before Firefox 41, it doesn't obey the crossorigin 属性。
IE 不支持 No Opera 完整支持 33 Safari 完整支持 11.1 WebView Android 完整支持 46 Chrome Android 完整支持 46 Firefox Android 完整支持 39 注意事项
完整支持 39 注意事项
注意事项 Before Firefox 41, it doesn't obey the crossorigin 属性。
Opera Android 完整支持 33 Safari iOS 完整支持 11.3 Samsung Internet Android 完整支持 4.0
prefetch 实验性 Chrome 完整支持 8 Edge 完整支持 12 Firefox 完整支持 2 IE 完整支持 11 Opera 完整支持 15 Safari 不支持 No WebView Android 完整支持 4.4 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 不支持 No Samsung Internet Android 完整支持 1.5
preload 实验性 Chrome 完整支持 50 Edge 完整支持 ≤79 Firefox 不支持 56 — 57 注意事项
不支持 56 — 57 注意事项
注意事项 Disabled due to various web compatibility issues (e.g. bug 1405761 ).
IE ? Opera 完整支持 37 Safari ? WebView Android 完整支持 50 Chrome Android 完整支持 50 Firefox Android 不支持 56 — 57 注意事项
不支持 56 — 57 注意事项
注意事项 Disabled due to various web compatibility issues (e.g. bug 1405761 ).
Opera Android ? Safari iOS ? Samsung Internet Android 完整支持 5.0
prerender 实验性 Chrome 完整支持 13 Edge 完整支持 79 Firefox 不支持 No IE 完整支持 11 Opera 完整支持 15 Safari 不支持 No WebView Android 完整支持 4.4 Chrome Android 完整支持 18 Firefox Android 不支持 No Opera Android 完整支持 14 Safari iOS 不支持 No Samsung Internet Android 完整支持 1.5

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

见实现注意事项。

可访问性关注

另请参阅

元数据

  • 最后修改:

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1