YouTip LogoYouTip

Att Link Sizes

## HTML <link> sizes Attribute The `sizes` attribute of the `` tag specifies the sizes of icon resources for visual media. This attribute is used to define the dimensions of favicons or application icons, allowing browsers to select the most appropriate resolution for the user's device. --- ## Definition and Usage * The `sizes` attribute is only used when the relation attribute is set to `rel="icon"` (or device-specific icon relations like `apple-touch-icon`). * It helps the browser choose the optimal icon size from multiple linked resources, preventing the download of unnecessarily large images or the scaling of images that are too small. * **HTML5 Standard:** The `sizes` attribute is a feature introduced in HTML5. --- ## Syntax ```html ``` --- ## Attribute Values | Value | Description | | :--- | :--- | | `HeightxWidth` | Specifies one or more sizes for the linked icon. The height and width must be separated by an "x" or "X" (e.g., `16x16`). Multiple sizes can be defined by separating them with a space. | | `any` | Specifies that the icon is scalable and can be rendered at any size (typically used for vector formats like SVG). | --- ## Code Examples ### 1. Single Icon Size Specify a standard 16x16 pixel favicon: ```html ``` ### 2. Multiple Icon Sizes Provide multiple sizes within a single link tag (often used for `.ico` files containing multiple resolutions): ```html ``` ### 3. Scalable Vector Icon (SVG) Use the `any` value for scalable vector graphics, allowing the browser to scale the icon perfectly to any required resolution: ```html ``` ### 4. Best Practice: Multiple Link Elements Modern web development often involves defining multiple `` tags with different sizes so that mobile devices, tablets, and desktop browsers can download only the asset they need: ```html ``` --- ## Browser Support and Considerations * **Modern Browsers:** All modern desktop and mobile browsers (including Google Chrome, Firefox, Microsoft Edge, Safari, and Opera) fully support the `sizes` attribute to select the best-fitting icon. * **Legacy Browsers:** Older browsers (such as Internet Explorer 11 and below) may ignore the `sizes` attribute and default to downloading the first icon declared or a standard `favicon.ico` file located at the root directory. * **MIME Type:** Always pair the `sizes` attribute with the correct `type` attribute (e.g., `image/png` or `image/svg+xml`) to help the browser identify the file format before downloading it.
← Att Menu LabelAtt Link Rev β†’