The attributes of the Link tag in HTML are used to link external resources and have the following main attributes: href: Specify the URL of the link resource rel: Define the relationship between the link and the current page type: Specify the MIME type of the link resource media: Specify which media types are applicable to sizes: Specify the size of the icon on different devices crossOrigin: Specify whether to allow cross-domain requests
Link tags are used in HTML to establish connections with external resources (such as style sheets, scripts, icons). It has the following main attributes:
1. href: Specifies the URL of the resource to be linked. This can be a local file or a remote file.
2. rel: Define the relationship between the link and the current page. Common rel values include:
3. type:Specifies the MIME type of the linked resource. For CSS, type is usually "text/css" and for icons, type is usually "image/vnd.microsoft.icon".
4. media: Specify which media types the link resource is suitable for. Common media values include:
5. sizes:Specify the size of the icon on different devices. For example, sizes="32x32" means the icon displays on a 32x32 pixel device.
6. crossOrigin: Specify whether to allow cross-domain requests. By default, crossOrigin is "anonymous", which means that only the resource's metadata can be read.
Example:
The following example shows a Link tag that links to a style sheet:
<code class="html"><link rel="stylesheet" type="text/css" href="style.css"></code>
The following example shows a link to a favicon Link tag:
<code class="html"><link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" sizes="32x32"></code>
The above is the detailed content of Attributes of link tag in html. For more information, please follow other related articles on the PHP Chinese website!