Interview Question

What is integrity attribute?

Integrity lets the browser verify a fetched resource against trusted metadata.

💡 Concept ✅ Quick Revision 🌐 HTML

Answer

The `integrity` attribute contains cryptographic metadata that lets the browser verify a fetched script or stylesheet before using it. β€’ It is written inside an element’s opening tag. β€’ The HTML Standard limits which elements may use it and which values are valid. β€’ Browsers apply the attribute when they process the element or the resource it controls.

💡 Simple Example

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">

⚡ Quick Revision

Integrity lets the browser verify a fetched resource against trusted metadata.