Home > Web Front-end > HTML Tutorial > Attributes of link tag in html

Attributes of link tag in html

下次还敢
Release: 2024-04-27 19:24:58
Original
1015 people have browsed it

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

Attributes of link tag in html

Attributes of the Link tag in HTML

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:

  • stylesheet: Link to a CSS style sheet
  • icon: Link to an icon
  • alternate:Link to an alternate language version or device version of the page

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:

  • all: Applies to all media types
  • print: Applies to print output only
  • screen: Only applicable to screen display

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>
Copy after login

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>
Copy after login

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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template