HTML integrity Attribute
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.
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-orsha512-followed by the base64-encoded digest of the file.
Applies To
Example
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.
Desktop





Tablets & Mobile





