Favorites

HTML as Attribute

as
HTML AttributeThis attribute is supported by all modern browsers.
Updated 22nd November 2026

The as attribute sets the type of content a <link rel="preload"> fetches, such as script, style, font or image, so it gets the right priority.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The as attribute of the <link> element tells the browser what type of resource is being fetched when rel="preload" or rel="modulepreload" is used. It is required for preloading: without a valid as value the browser cannot set the correct priority, request headers and Content Security Policy, and may download the resource twice.

The value must match how the resource will later be used, for example style for a stylesheet, script for a script, font for a web font (which also needs the crossorigin attribute) and image for an image.

Syntax

<link rel="preload" href="URL" as="type">

Values

  • audio, video, trackMedia files and text tracks.
  • documentAn HTML document to embed in a frame.
  • embed, objectResources for <embed> and <object>.
  • fetchA resource fetched with fetch() or XMLHttpRequest.
  • fontA web font.
  • imageAn image.
  • scriptA JavaScript file.
  • styleA CSS stylesheet.
  • workerA worker script.

Applies To

Example

<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/main.css" as="style">
Open in editor

Browser Support

The following information will show you the current browser support for the HTML as attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.