What is use of rel Attribute in HTML ?
Last Updated :
19 Feb, 2024
The “rel” attribute in HTML is used to define the relationship between the current document and the linked document or resource specified by the <a>
(anchor) tag or the <link>
tag. It provides additional context or metadata about the linked resource, aiding in navigation, search engine optimization, and accessibility.
Syntax
<a href="URL" rel="relationship_type">Link Text</a>
<link rel="relationship_type" href="stylesheet.css">
Key Point |
Description |
Relationship Type |
The value of the “rel” attribute specifies the type of relationship between the current document and the linked resource. |
Common Values |
Common values for the “rel” attribute include “stylesheet”, “icon”, “nofollow”, “canonical”, “prev”, “next”, and “alternate”. |
Link Types |
The “rel” attribute is commonly used in anchor tags <a> and link tags <link> to specify relationships between documents, stylesheets, icons, and alternate versions of content. |
SEO and Accessibility |
Properly defining relationships with the “rel” attribute can improve search engine rankings, enhance accessibility, and provide better user experience. |
Features
- Defining Relationships: Specify the relationship between the current document and the linked resource using the “rel” attribute
<a href="https://example.com/page2" rel="next">Next Page</a>
- Linking Stylesheets: Use the “rel” attribute to link external stylesheets to the HTML document
<link rel="stylesheet" href="styles.css">
- SEO Optimization: Utilize specific “rel” attribute values such as “canonical” to indicate the preferred version of a page for search engines.
<link rel="canonical" href="https://example.com/page">
Share your thoughts in the comments
Please Login to comment...