concept

Content security policy — CSS reference

Content Security Policy restricts which style sources may be used. Prefer an HTTP response header with a carefully designed policy; a meta policy supports a subset of directives. Inline styles require appropriate authorization such as a matching nonce or hash where applicable. CSP is defense in depth, not a substitute for keeping untrusted content out of CSS. The local example is an ordinary inline style; a separate isolated test verifies a restrictive meta policy blocking it.

Formal Syntax & Structure

css syntaxcss
Content-Security-Policy: style-src 'self'

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>content-security-policy</title><style>body{margin:8px;font:16px/1.5 sans-serif;color:black;background:white}#a{box-sizing:border-box}#a{color:blue}</style><body><div id="a">Example</div></body></html>
CSS Reference