HTML link rel
Created By: chatGPT
In HTML, the link element is used to define the relationship between the current document and an external resource. This is commonly used to link to stylesheets. The rel attribute specifies the relationship type. Here is an example of how to use it to link to a CSS stylesheet:
<link rel="stylesheet" href="styles.css">
The rel attribute can have various values depending on what you want to achieve. Some common values include:
<link rel="icon" href="favicon.ico">
<link rel="preconnect" href="https://example.com">
<link rel="dns-prefetch" href="https://example.com">
When you are using multiple link elements for different purposes, make sure each has its own rel value to avoid confusion and ensure proper functionality.
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon" href="apple-icon.png">
To ensure that your links function as intended, always follow best practices for defining the href attribute, which must be a URL pointing to the external resource or file.
<link rel="preload" href="script.js" as="script">