Search This Blog

Saturday, February 19, 2022

HTML: link tag

 

HTML: <link> tag

This HTML tutorial explains how to use the HTML element called the <link> tag with syntax and examples.

Description

The HTML <link> tag links an external resource, such as a css file, to the HTML document. This tag is also commonly referred to as the <link> element.

HTML <link> Tag Syntax - Linking a Stylesheet

The syntax for linking a stylesheet using the HTML <link> tag is:

<head>
<link rel="stylesheet" href="/css/main.css" type="text/css">
</head>

or in XHTML, the syntax for the <link> tag is:

<head>
<link rel="stylesheet" href="/css/main.css" type="text/css" />
</head>

Attributes

In addition to the Global Attributes, the following is a list of attributes that are specific to the <link> tag:

AttributeDescriptionHTML Compatibility
charsetCharacter encoding of the linked resourceObsolete
disabledDisable a link relationshipNon-standard, Only used by some Microsoft browsers
hrefURL of the linked resourceHTML 4.01, HTML5
hreflangLanguage of the linked resourceHTML 4.01, HTML5
mediaMedia that the linked resource applies toHTML 4.01, HTML5
methodsInformation about functions that might be performed on objectNon-standard
relType of linked resourceHTML 4.01, HTML5
revRelationship of current document to linked documentObsolete
sizesSizes of the icons (when rel contains icon)HTML5
targetFrame name that has defined linking relationshipNon-standard
typeMIME type of the linked resourceHTML 4.01, HTML5

Note

  • The HTML <link> element is found within the <head> tag.
  • The <link> tag is most commonly used to link a stylesheet or css file to the HTML document.

Browser Compatibility

The <link> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <link> tag below, exploring examples of how to use the <link> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.



No comments:

Post a Comment

HTML: link tag

  HTML:   <link> tag This HTML tutorial explains how to use the HTML element called the   <link> tag   with syntax and examples....