Guides/Create content/Code/Add custom HTML

Add custom HTML

Last reviewed on May 1, 2026

Use the Custom HTML block to add HTML code and preview it as you edit it. This guide will show you how to use this block to add code to your website.

Before you begin

Before you begin, the Custom HTML block is for adding raw HTML code to a single page or post. It’s not always the right tool. If your goal matches one of the cases below, the linked guide is a faster route:

  • Embed a video, map, social post, or third-party service (YouTube, Spotify, Instagram, Giphy, Pinterest, and many others): see Embed content from other platforms. The Embed block works on every plan and supports many popular services without any custom code.
  • Collect contact details, signups, or feedback: see Form block. The Form block builds a working form without HTML.
  • Add CSS styling to your site: see Add custom CSS.
  • Add code to your site’s headers (verification meta tags, third-party scripts that load site-wide): see Add code to headers.

Add the Custom HTML block

To add the Custom HTML block, follow these steps:

  1. Go to your site’s dashboard and select the page, post, or template you want to add the HTML to.
  2. Click the + block inserter icon and search for “HTML”.
  3. Click the Custom HTML block to add it to your content.
A box drawn around the Custom HTML block in the block selector.

For more information, visit our detailed instructions on adding blocks.

Add your HTML

Once you’ve added the block, follow these steps to add your HTML code:

  1. Click the “Edit HTML” button.
The HTML block with an Edit HTML button.
  1. Write or paste your HTML code on the left side of the editor.
    • As you compose your HTML, you will see a preview of the code on the right side.
  2. When you’re satisfied, click the Update button to save your changes.
The HTML editor with code on the left and a preview on the right.

You will see the result of your HTML code in the editor. To make changes, click the “Edit HTML” button in the block toolbar.

Supported HTML

HTML is a computer language that tells browsers how to display website content. WordPress.com allows the following HTML tags on all plans:

  • a
  • address
  • abbr
  • acronym
  • area
  • article
  • aside
  • b
  • big
  • blockquote
  • br
  • caption
  • cite
  • class
  • code
  • col
  • del
  • details
  • dd
  • div
  • dl
  • dt
  • em
  • figure
  • figcaption
  • footer
  • font
  • h1, h2, h3, h4, h5, h6
  • header
  • hgroup
  • i
  • img
  • ins
  • kbd
  • li
  • map
  • mark
  • ol
  • p
  • pre
  • q
  • rp
  • rt
  • rtc
  • ruby
  • s
  • section
  • small
  • span
  • strike
  • strong
  • sub
  • summary
  • sup
  • table
  • tbody
  • td
  • tfoot
  • th
  • thead
  • tr
  • tt
  • u
  • ul
  • var

To add the following tags, you will need a paid plan with hosting features activated. Learn how to activate your plan’s hosting features.

embed, frame, iframe, form, input, object, textarea, script, style, link

For more information on the types of code you can add to your website, as well as alternatives when a type of code is not supported, visit our guide on adding code to your website.

Troubleshoot common issues

If your HTML code does not appear as expected after saving, check the following common causes.

Code disappears after saving

WordPress.com filters certain HTML tags for security. Tags like iframe, script, style, form, embed, and object require a paid plan with hosting features activated.

If your code disappears or is partially removed after you save, work through these checks in order:

  1. Check your plan. Go to your site’s dashboard and select Upgrades → Plans. The Custom HTML block accepts restricted tags only on a paid plan. If you’re on the free plan, upgrade to any paid plan to continue.
  2. Activate hosting features. A paid plan alone is not enough — hosting features must also be active. Install at least one plugin on your site to activate your plan to accept custom code.
  3. Re-enter your code. Once your plan is paid and hosting features are active, paste the code into the Custom HTML block again and save.

If your code is still removed after activating hosting features, the tag may not be supported in this context, or the third-party service may publish embed code that uses unsupported markup. Try the Embed block instead, or see Resolve “unexpected or invalid content” errors below.

Embed third-party content without custom code

If you’re trying to embed content from a third-party service — videos, music, maps, social posts, calendars, newsletters, or document viewers — use the Embed block instead. The Embed block works on every plan, does not require you to write HTML, and supports services such as YouTube, Vimeo, Spotify, X, Instagram, TikTok, and many others.

If the Embed block does not list your service, the service likely needs an iframe or script. Add the embed code to a Custom HTML block on a paid plan with hosting features activated.

Resolve “unexpected or invalid content” errors

If you see a message that says your block contains unexpected or invalid content, the HTML in the block may be malformed or may have changed. Select “Attempt Block Recovery” to let the editor fix the issue automatically. If the error persists, see our guide on resolving block errors for additional options.

Was this guide helpful for you?

Not quite what you're looking for? Get Help!

Copied to clipboard!