HTML - Integrity attribute

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - About

integrity is an attribute of the fetch elements.

Its value is a digest that controls that the file was not altered in transit.


3 - Example

If the calculation output with a sha384 was:


A link element for instance would be:

<link rel="stylesheet" href="stylesheet.css "integrity="sha384-ZYfZnVukOuh/gRpU9uN+T9XwwRFJ9Y+0Ylk3zKvI184omb/HoOtQ0F8Iol7Nix7q">

4 - Management

4.1 - Calculation

4.1.1 - Online

4.1.2 - Offline

The integrity can be calculated with the following command line.

It calculate the digest with a sha (256 or 384) and apply the base64 algorithm above.

openssl dgst -sha256 -binary stylesheet.css | openssl base64 -A
openssl dgst -sha384 -binary stylesheet.css | openssl base64 -A