YouTip LogoYouTip

Att Link Href

## HTML `` href Attribute The `href` attribute of the `` tag specifies the location (URL) of the external resource being linked to the current document. It is most commonly used to link to external CSS stylesheets, but it is also used for favicons, prefetching resources, and establishing relationships with other documents. --- ## Browser Support The `href` attribute is universally supported by all modern web browsers: * Google Chrome * Mozilla Firefox * Safari * Microsoft Edge * Opera --- ## Definition and Usage The `href` (Hypertext Reference) attribute defines the destination address of the linked resource. Without this attribute, the `` element cannot load any external files. To establish a proper link, the `href` attribute is almost always paired with the `rel` (relationship) attribute, which defines how the current document relates to the target resource (e.g., `rel="stylesheet"`). --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | **`URL`** | The URL of the linked resource or document.

**Possible values:**
β€’ **Absolute URL:** Points to an external website (e.g., `href="https://www.example.com/css/theme.css"`).
β€’ **Relative URL:** Points to a file within the same website (e.g., `href="/themes/theme.css"` or `href="theme.css"`). | --- ## Code Examples ### Example 1: Linking to an External Stylesheet This is the most common use case for the `` tag and its `href` attribute. ```html Linking External CSS

Hello World

This page is styled using an external stylesheet.

``` ### Example 2: Adding a Website Favicon You can use the `href` attribute to point to an icon file that will display in the browser tab. ```html ``` ### Example 3: Resource Hinting (DNS Prefetch) You can use `href` to tell the browser to resolve DNS domain names before a user clicks a link, improving page load performance. ```html ``` --- ## HTML 4.01 vs. HTML5 There are no functional differences in how the `href` attribute behaves between HTML 4.01 and HTML5. However, in HTML5, the `type` attribute (e.g., `type="text/css"`) is no longer strictly required when linking CSS stylesheets, making the syntax cleaner: ```html ```
← Att Link HreflangAtt Link Charset β†’