Favorites

HTML integrity Attribute

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

The integrity attribute holds a hash of a script or style sheet. The browser refuses the file if its contents don't match, protecting against tampering.

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 integrity attribute enables Subresource Integrity (SRI): it contains a cryptographic hash of the expected content of a script or stylesheet. The browser computes the hash of the downloaded file and refuses to use it if the two do not match, which protects the page if a CDN or third-party server is compromised and serves modified code.

The value is the hash algorithm (sha256, sha384 or sha512), a dash and the base64-encoded hash, for example sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC. Several hashes can be given separated by spaces. Resources from another origin must also be served with CORS, so use it together with crossorigin="anonymous".

Syntax

<tagname src="URL" integrity="sha384-hash" crossorigin="anonymous">

Values

  • algorithm-hashOne or more space-separated hashes, each written as sha256-, sha384- or sha512- followed by the base64-encoded digest of the file.

Applies To

Example

<script src="https://cdn.example.com/library.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML integrity 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.