How to use link tag in html

下次还敢
Release: 2024-04-27 21:06:33
Original
417 people have browsed it

This article provides the usage of link tags in HTML, including: self-closing tags used to declare external resources or specify document relationships. The format is: . The rel attribute specifies the resource relationship, which can be stylesheet, icon, alternate, next/prev. The type attribute specifies the resource media type, such as text, style sheet, etc. The href attribute specifies the resource URL. Can contain other attributes such as media (media type), sizes (size), charset (character set).

How to use link tag in html

Usage of link tag in HTML

The link tag is used to declare external resources or specify documents in HTML documents The relationship between. It is a self-closing tag with no closing tag.

Usage format:

<code class="html"><link rel="type" href="URL" /></code>
Copy after login

Where:

  • ##rel:Specifies the relationship between resources and documents.
  • type: Specify the media type of the resource (such as text, style sheet, etc.).
  • href: Specifies the URL of the resource.

Type attribute:

The rel attribute of the link tag can specify the following types of relationships:

  • stylesheet: Link to external style sheet.
  • icon: The favicon of the specified document.
  • alternate: Specify a different version of the document, such as mobile view or print view.
  • next/prev: Specify the next/previous article in the document.

Other attributes:

The link tag can also contain the following attributes:

  • media: specified The type of media the resource should be used for (e.g. screen, print, etc.).
  • sizes: Specifies the size of the resource (related to favicon).
  • charset: Specifies the character set of the resource.

Example:

The following example links an external style sheet into an HTML document:

<code class="html"><link rel="stylesheet" type="text/css" href="style.css" /></code>
Copy after login

Note:

    The link tag can be placed anywhere in the HTML document, but is usually placed in the head element.
  • link tags can link to HTTP, HTTPS, or data URIs.
  • link tags can have multiple rel attribute values ​​at the same time.

The above is the detailed content of How to use 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!