Safeguard
Developer Tools•

Can you set a Content Security Policy with a meta tag on a static site?

A CSP meta tag works for client-rendered apps without header control, but it lacks features like report-only mode and report-to. See what to use instead.

Safeguard Security Team
4 min read

Yes, a meta tag with http-equiv="Content-Security-Policy" works, and MDN calls it useful for client-side rendered single page apps with static resources. But it does not support every CSP feature: no report-only mode and no report-to. Use real response headers whenever your host allows it.

The syntax

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; object-src 'none'; base-uri 'self'">

Place it early in the head, before any element it should govern. The policy applies to content that loads after it, so a script tag above the meta element is not covered.

What you lose

MDN documents specific gaps.

FeatureIn a meta tag?
Enforcing policy with most fetch directivesYes
Content-Security-Policy-Report-OnlyNo. MDN says a report-only policy cannot be delivered in a meta element
report-to directiveNo. MDN says it is not supported in the meta element
Anything else beyond the basicsCheck the current MDN page. MDN states the option does not support all CSP features

Losing reporting is the biggest practical cost. Without report-only mode, you cannot trial a stricter policy quietly, and without report-to you will not hear about violations in production.

Static hosting options

  1. Headers at the host. Many static hosts, CDNs and reverse proxies can attach response headers by path. This is the preferred option, and it lets you add reporting and a report-only trial policy.
  2. A tiny edge function or proxy that adds headers, if the host itself cannot.
  3. The meta tag, as a fallback, when you have no header control at all.
  4. Hash based directives in either case. A static page cannot mint a nonce for each response, and MDN says hash based policies suit static pages and client-side rendering, with the catch that each script change means a new hash.

Testing a meta policy

  1. Load the page with the browser console open. Violations print there with the directive name.
  2. Test with a deliberately injected inline script in a test build, to confirm the policy blocks it.
  3. Confirm the meta tag sits above every script and style link it should cover.
  4. Re-test after every build, since a bundler or framework may reorder head elements.

A realistic plan

Start with the meta tag if that is what you have, using a modest policy: default-src 'self', object-src 'none', base-uri 'self'. Add third-party hosts only when a page breaks, and record why. Move to headers when you next touch your hosting, then add reporting and tighten.

Headers set on the server also help with controls that have no meta equivalent. See HTTP security headers hardening guide for the wider set.

Try it yourself

Click through the web app scan to see how missing or weak policy headers appear as findings, then check which of them a meta tag could resolve.

Click through it at your own pace, or open it full screen.

Quick check

Can a meta tag send violation reports?

No. MDN says report-to is not supported in a meta element, and report-only policies cannot be delivered that way.

Is a meta CSP as good as a header?

It enforces the supported directives, but it is less complete, and it only covers content that comes after it in the document.

Safeguard scans the dependencies behind your static site and produces an SBOM. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.