HTML attribute: rel - HTML: HyperText Markup Language 编辑
Draft
This page is not complete.
The rel
attribute defines the relationship between a linked resource and the current document. Valid on <link>
, <a>
, <area>
, and <form>
, the supported values depend on the element on which the attribute is found.
The /wiki/en-US/docs/Web/HTML/Attributes/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.
rel value | Description |
| and
|
|
---|---|---|---|---|
alternate | Alternate representations of the current document. | Link | Link | Not allowed |
author | Author of the current document or article. | Link | Link | Not allowed |
bookmark | Permalink for the nearest ancestor section. | Not allowed | Link | Not allowed |
canonical | Preferred URL for the current document. | Link | Not allowed | Not allowed |
dns-prefetch | Tells the browser to preemptively perform DNS resolution for the /wiki/en-US/docs/Web/HTML/Attributes/target resource's origin | External Resource | Not allowed | Not allowed |
external | The referenced document is not part of the same site /wiki/en-US/docs/Web/HTML/Attributes/as the current document. | Not allowed | Annotation | Annotation |
help | Link to context-sensitive help. | Link | Link | Link |
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. | Link | Link | Link |
manifest | Web app manifest | Link | 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 /wiki/en-US/docs/Web/HTML/Attributes/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. | Link | Link | Link |
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., h/wiki/en-US/docs/Web/HTML/Attributes/as an appropriate/wiki/en-US/docs/Web/HTML/Attributes/target attribute value). | Not allowed | Annotation | Annotation |
noreferrer | No Referer header will be included. Additionally, h/wiki/en-US/docs/Web/HTML/Attributes/as the same effect /wiki/en-US/docs/Web/HTML/Attributes/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., h/wiki/en-US/docs/Web/HTML/Attributes/as "_blank " /wiki/en-US/docs/Web/HTML/Attributes/as /wiki/en-US/docs/Web/HTML/Attributes/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 /wiki/en-US/docs/Web/HTML/Attributes/target resource's origin. | External Resource | Not allowed | Not allowed |
prefetch | Specifies that the user agent should preemptively fetch and cache the /wiki/en-US/docs/Web/HTML/Attributes/target resource /wiki/en-US/docs/Web/HTML/Attributes/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 /wiki/en-US/docs/Web/HTML/Attributes/target resource for current navigation according to the potential destination given by the /wiki/en-US/docs/Web/HTML/Attributes/as attribute (and the priority /wiki/en-US/docs/Web/HTML/Attributes/associated with the corresponding destination). | External Resource | Not allowed | Not allowed |
prerender | Specifies that the user agent should preemptively fetch the /wiki/en-US/docs/Web/HTML/Attributes/target resource and process it in a way that helps deliver a f/wiki/en-US/docs/Web/HTML/Attributes/aster 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. | Link | Link | Link |
search | Gives a link to a resource that can be used to search through the current document and its related pages. | Link | Link | Link |
stylesheet | 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 | Link | Not allowed |
The rel
attribute is relevant to the <link>
, <a>
, <area>
, and <form>
elements, but some values only relevant to a subset of those elements. Like all HTML keyword attribute values, these values are c/wiki/en-US/docs/Web/HTML/Attributes/ase-insenstive.
The rel
attribute h/wiki/en-US/docs/Web/HTML/Attributes/as no default value. If the attribute is omitted or if none of the values in the attribute are supported, then the document h/wiki/en-US/docs/Web/HTML/Attributes/as no particular relationship with the destination resource other than there being a hyperlink between the two. In this c/wiki/en-US/docs/Web/HTML/Attributes/ase, on <link>
and <form>
, if the rel
attribute is absent, h/wiki/en-US/docs/Web/HTML/Attributes/as 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 c/wiki/en-US/docs/Web/HTML/Attributes/ase-insensitive.
Values
If there are multiple <link rel="icon">
s, the browser uses their /wiki/en-US/docs/Web/HTML/Attributes/media
attribute, /wiki/en-US/docs/Web/HTML/Attributes/type
and /wiki/en-US/docs/Web/HTML/Attributes/sizes
attributes to select the most appropriate icon. If several icons are equally appropriate, the l/wiki/en-US/docs/Web/HTML/Attributes/ast 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.
Note: Apple's iOS does not use this link /wiki/en-US/docs/Web/HTML/Attributes/type, nor the /wiki/en-US/docs/Web/HTML/Attributes/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
respectively.
The shortcut
link /wiki/en-US/docs/Web/HTML/Attributes/type is often seen before icon
, but this link /wiki/en-US/docs/Web/HTML/Attributes/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
stylesheet
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="highcontr/wiki/en-US/docs/Web/HTML/Attributes/ast.css" title="High contr/wiki/en-US/docs/Web/HTML/Attributes/ast">
- With an /wiki/en-US/docs/Web/HTML/Attributes/hreflang attribute that differs from the document language, it indicates a translation.
- With the /wiki/en-US/docs/Web/HTML/Attributes/type attribute, it indicates that the referenced document is the same content in a different format. For example, with
/wiki/en-US/docs/Web/HTML/Attributes/type="application/rss+xml"
it creates a hyperlink referencing a syndication feed.<link rel="alternate" /wiki/en-US/docs/Web/HTML/Attributes/type="application/atom+xml" href="posts.xml" title="Blog">
- Both the /wiki/en-US/docs/Web/HTML/Attributes/hreflang and /wiki/en-US/docs/Web/HTML/Attributes/type attributes specify links to versions of the document in an alternative format and language, intended for other /wiki/en-US/docs/Web/HTML/Attributes/media:
<link rel=alternate href="/fr/html/print" /wiki/en-US/docs/Web/HTML/Attributes/hreflang=fr /wiki/en-US/docs/Web/HTML/Attributes/type=text/html /wiki/en-US/docs/Web/HTML/Attributes/media=print title="French HTML (for printing)"> <link rel=alternate href="/fr/pdf" /wiki/en-US/docs/Web/HTML/Attributes/hreflang=fr /wiki/en-US/docs/Web/HTML/Attributes/type=application/pdf title="French PDF">
- With the
author
- Indicates the author of the current document or article. Relevant for
<link>
,<a>
, and<area>
elements, theauthor
keyword creates a hyperlink. With<a>
and<area>
, it indicates the linked document (ormailto:
) 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 /wiki/en-US/docs/Web/HTML/Attributes/asrel="alternate"
bookmark
- Relevant /wiki/en-US/docs/Web/HTML/Attributes/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 le/wiki/en-US/docs/Web/HTML/Attributes/ast 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 /wiki/en-US/docs/Web/HTML/Attributes/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 /wiki/en-US/docs/Web/HTML/Attributes/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>
, and<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>
, and<area>
, thehelp
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 defaultcursor
will behelp
instead ofpointer
. 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/wiki/en-US/docs/Web/HTML/Attributes/media
attribute,/wiki/en-US/docs/Web/HTML/Attributes/type
, and/wiki/en-US/docs/Web/HTML/Attributes/sizes
attributes to select the most appropriate icon. If several icons are equally appropriate, the l/wiki/en-US/docs/Web/HTML/Attributes/ast 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 w/wiki/en-US/docs/Web/HTML/Attributes/as not supported for
rel="icon"
there is also an open issue for Chrome.Note: Apple's iOS does not use this link /wiki/en-US/docs/Web/HTML/Attributes/type, nor the
/wiki/en-US/docs/Web/HTML/Attributes/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-standardapple-touch-icon
andapple-touch-startup-image
respectively.The
shortcut
link /wiki/en-US/docs/Web/HTML/Attributes/type is often seen beforeicon
, but this link /wiki/en-US/docs/Web/HTML/Attributes/type is non-conforming, ignored and web authors must not use it anymore.license
Valid on the
<a>
,<area>
,<form>
,<link>
elements, thelicense
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 /wiki/en-US/docs/Web/HTML/Attributes/as a whole. Only the data on the page can indicate this.<link rel="license" href="#license">
Note: 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, settingrel="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 /wiki/en-US/docs/Web/HTML/Attributes/types:modulepreload
. next
- Relevant to
<form>
,<link>
,<a>
, and<area>
, thenext
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 /wiki/en-US/docs/Web/HTML/Attributes/assume that document will be fetched next, and treat it /wiki/en-US/docs/Web/HTML/Attributes/as a resource hint. nofollow
- Relevant to
<form>
,<a>
, and<area>
, thenofollow
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>
, and<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., h/wiki/en-US/docs/Web/HTML/Attributes/as an appropriate/wiki/en-US/docs/Web/HTML/Attributes/target
attribute value). In other words, it makes the link behave /wiki/en-US/docs/Web/HTML/Attributes/as ifwindow.opener
were null and/wiki/en-US/docs/Web/HTML/Attributes/target="_parent"
were set.
This is the opposite of opener. noreferrer
- Relevant to
<form>
,<a>
, and<area>
, including this value makes the referrer unknown (noReferer
header will be included), and opens the creates a top-level browsing context, /wiki/en-US/docs/Web/HTML/Attributes/as ifnoopener
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., h/wiki/en-US/docs/Web/HTML/Attributes/as "
_blank
" /wiki/en-US/docs/Web/HTML/Attributes/as/wiki/en-US/docs/Web/HTML/Attributes/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 /wiki/en-US/docs/Web/HTML/Attributes/target resource's origin.
prefetch
- Specifies that the user agent should preemptively fetch and cache the /wiki/en-US/docs/Web/HTML/Attributes/target resource /wiki/en-US/docs/Web/HTML/Attributes/as it is likely to be required for a followup navigation.
preload
- Specifies that the user agent must preemptively fetch and cache the /wiki/en-US/docs/Web/HTML/Attributes/target resource for current navigation according to the potential destination given by the
/wiki/en-US/docs/Web/HTML/Attributes/as
attribute (and the priority /wiki/en-US/docs/Web/HTML/Attributes/associated with the corresponding destination). prerender
- Specifies that the user agent should preemptively fetch the /wiki/en-US/docs/Web/HTML/Attributes/target resource and process it in a way that helps deliver a f/wiki/en-US/docs/Web/HTML/Attributes/aster response in the future.
prev
Similar to the next keyword, relevant to
<form>
,<link>
,<a>
, and<area>
, theprev
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
previous
is incorrect and should not be used.search
Relevant to
<form>
,<link>
,<a>
, and<area>
elements, thesearch
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.If the
/wiki/en-US/docs/Web/HTML/Attributes/type
attribute is set toapplication/opensearchdescription+xml
the resource is an OpenSearch plugin that can be e/wiki/en-US/docs/Web/HTML/Attributes/asily added to the interface of some browsers like Firefox or Internet Explorer.stylesheet
Valid for the
<link>
element, it imports an external resource to be used /wiki/en-US/docs/Web/HTML/Attributes/as a stylesheet. The/wiki/en-US/docs/Web/HTML/Attributes/type
attribute is not needed /wiki/en-US/docs/Web/HTML/Attributes/as it's atext/css
stylesheet, /wiki/en-US/docs/Web/HTML/Attributes/as that is the default value. If it's not a stylesheet of /wiki/en-US/docs/Web/HTML/Attributes/typetext/css
it is best to declare the /wiki/en-US/docs/Web/HTML/Attributes/type.While this attribute defines the link /wiki/en-US/docs/Web/HTML/Attributes/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.
When used with the alternate keyword, it defines an alternative style sheet. In this c/wiki/en-US/docs/Web/HTML/Attributes/ase, include a non-empty
title
.The external stylesheet will not be used or even downloaded if the /wiki/en-US/docs/Web/HTML/Attributes/media does not match the value of the
/wiki/en-US/docs/Web/HTML/Attributes/media
attribute.Requires the use of the CORS protocol for cross-origin fetching.
tag
- Valid for the
<a>
, and<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 /wiki/en-US/docs/Web/HTML/Attributes/type is not meant for tags within a tag cloud, /wiki/en-US/docs/Web/HTML/Attributes/as those tags apply to a group of pages, where/wiki/en-US/docs/Web/HTML/Attributes/as thetag
value of therel
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" /wiki/en-US/docs/Web/HTML/Attributes/sizes="144x144" href="/static/img/favicon144.e7e21ca263ca.png"> <!-- iPhone with high-resolution Retina display: --> <link rel="apple-touch-icon-precomposed" /wiki/en-US/docs/Web/HTML/Attributes/sizes="114x114" href="/static/img/favicon114.d526f38b09c5.png"> <!-- first- and second-generation iPad: --> <link rel="apple-touch-icon-precomposed" /wiki/en-US/docs/Web/HTML/Attributes/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"> <!-- b/wiki/en-US/docs/Web/HTML/Attributes/asic favicon --> <link rel="shortcut icon" href="/static/img/favicon32.7f3da72dcea1.png">
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'rel attribute' in that specification. | Living Standard | Added opener . Made noopener default for /wiki/en-US/docs/Web/HTML/Attributes/target="_blank" . |
HTML5 The definition of 'rel attribute' in that specification. | Recommendation | Added tag , search , prefetch , noreferrer , nofollow , icon , and author .Renamed copyright to license .Removed start , chapter , section , subsection , and appendix |
Preload The definition of 'preload' in that specification. | Candidate Recommendation | Added preload . |
Resource Hints The definition of 'preconnect' in that specification. | Working Draft | Added dns-prefetch , preconnect , and prerender values. |
HTML 4.01 Specification The definition of 'link /wiki/en-US/docs/Web/HTML/Attributes/types' in that specification. | Recommendation | Added alternate , stylesheet , start , chapter , section , subsection , appendix , and bookmark .Renamed previous to prev .Removed top , and search . |
Unknown The definition of '<link>' in that specification. | Unknown (Obsolete) | Added top , contents , index , glossary , copyright , next , previous , help , and search . |
RFC 1866: HTML 2.0 | Unknown(Obsolete) | Initial definition. |
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, ple/wiki/en-US/docs/Web/HTML/Attributes/ase check out https://github.com/mdn/browser-compat-data and send us a pull request.
Accessibility concerns
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论