HTML Tutorial
<link>
The <link>
tag establishes a link between an HTML document and external resources, such as stylesheets, scripts, and other documents. It enhances the document's functionality and presentation without directly including the content within the HTML code.
<link>
href
: Specifies the location of the linked resource.rel
: Defines the relationship between the HTML document and the linked resource. Common values include "stylesheet" for stylesheets and "script" for scripts.type
: Indicates the type of linked resource. For stylesheets, it's "text/css"; for scripts, it's "text/javascript".media
: Specifies the media types for which the linked resource is applicable. Common values include "all" for all media types and "print" for printed documents.<link>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="script" type="text/javascript" href="script.js">
Exploring the <link>
Tag: An HTML Example
<!DOCTYPE html>
<html>
<head>
<title>Exploring the <link> Tag</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Welcome to the <link> Tag</h1>
<p>This tag allows us to link external resources to our HTML document.</p>
</body>
</html>
In this example, we link to an external stylesheet named "styles.css" using the <link>
tag. When the browser loads the HTML document, it fetches the stylesheet and applies its styles to the document, enhancing its presentation.