Content Security Policy (CSP)Baseline · Widely available
Content Security Policy (CSP) helps to mitigate certain security threats, including cross-site scripting (XSS) and clickjacking attacks. It consists of a set of directives from a website to a browser, which instruct the browser to restrict the things that the site is allowed to do.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Aug 2, 2016. Widely available since Feb 2, 2019.
Browser support
DesktopChrome
1–24Not supported
25+Supportedsince Feb 21, 2013
Current: 155Edge
12–13Not supported
14+Supportedsince Aug 2, 2016
Current: 154Firefox
1–22Not supported
23+Supportedsince Aug 6, 2013
Current: 157Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27MobileChrome Android
18–18Not supported
25+Supportedsince Feb 27, 2013
Current: 155Firefox Android
4–22Not supported
23+Supportedsince Aug 6, 2013
Current: 157Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: securitypolicyviolation event.
Feature detection
JS · check before using
if ("HTMLIFrameElement" in globalThis && "csp" in HTMLIFrameElement.prototype) {
// HTMLIFrameElement.csp is available
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (52). The overall table above shows when the whole feature works.