Website Security Q&As Logo
Website Security Q&As Part of the Q&A Network
Q&A Logo

How can I prevent clickjacking on my website?

Asked on Oct 17, 2025

Answer

To prevent clickjacking on your website, you should use the HTTP header "X-Frame-Options" or the "Content-Security-Policy" frame-ancestors directive to control how your website can be embedded in frames.
<!-- BEGIN COPY / PASTE -->
    X-Frame-Options: DENY
    <!-- END COPY / PASTE -->
Additional Comment:
  • The "X-Frame-Options" header can be set to "DENY" to prevent any domain from framing your site, or "SAMEORIGIN" to allow only your site to frame it.
  • For more granular control, use the "Content-Security-Policy" directive frame-ancestors 'none' or specify trusted domains.
  • Ensure these headers are set on all pages to provide consistent protection across your site.

✅ Answered with Security best practices.


← Back to All Questions
The Q&A Network