21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

How to Edit HTML in WordPress (Block Editor & Widgets)

Quick answer

To edit HTML in WordPress, open the page and choose Edit as HTML from a block's three-dot menu, or Code editor from the top-right Options menu for the whole page. New embeds go in a Custom HTML block: paste the markup, preview, then update. Theme files belong in a child theme.

For WordPress site owners in India who need to place an embed, fix one block, or change a template without breaking the theme.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
7
Updated
14 Nov 2026
Written by
WebJi® team

Where can you edit HTML in WordPress?

WordPress gives you four places to edit HTML, and the right one depends on scope: a block for one snippet in one page, a widget or template part for header and footer areas, and a child theme for template files. Pasting a full HTML document anywhere in a post is wrong — a post holds fragments, not html, head and body tags.

Four ways to edit HTML in WordPress, by scope
MethodUse it forYou are done when
Custom HTML blockAn embed, form or button inside one pagePreview shows the embed, then Update saves
Edit as HTML / Code editorFixing one block, or markup across a whole pageEdit visually shows every block with no invalid-content warning
Widget or Site Editor template partSidebar, header or footer HTMLThe public page shows the snippet outside the post
Child theme templateheader.php, single.php, block templatesA parent theme update leaves your copy in place

Who you are logged in as matters too: only Administrators on a single WordPress site can save script and iframe tags. Authors and Contributors lose those tags on save — the sanitization section below explains why.

How do you add HTML with a Custom HTML block?

The Custom HTML block is the home for any embed, form or button inside one page: paste the fragment, preview it, then update the page. It is deliberately dumb — it outputs almost exactly what you paste.

  1. In wp-admin, open Pages or Posts and edit the page.
  2. Click the block inserter (+) and choose Custom HTML.
  3. Paste the markup for that embed only — never a full document.
  4. Click Preview on the block; you should see the embed, not the tags.
  5. Click Update, then open the public page in a private window so a cached copy cannot hide the change.

If the embed vanishes after Update, the account that saved it is not allowed to store that tag — save again as an Administrator on a single site before you blame a plugin.

How do you edit one block or the whole page as HTML?

Choose Edit as HTML from a block's three-dot menu to change that block; choose Code editor from the top-right Options menu to edit every block on the page at once. They are the same editor at two zoom levels.

  1. Select the block, open its three-dot menu, and choose Edit as HTML.
  2. Change the tags, then switch back to Edit visually. If WordPress reports invalid content, undo — do not click Attempt recovery unless you can compare the two versions it shows.
  3. For the whole page, open the three-dot Options menu at the top right and choose Code editor.
  4. Leave the block comments such as <!-- wp:paragraph --> exactly where they are: deleting one deletes that block when you leave the code editor.
  5. Choose Exit code editor, click Update, and reload the public page privately.

On the Classic Editor plugin, or inside a Classic block, the same job is done by the Text tab — paste tags there, never into the Visual tab, which will display them as text.

How do you edit theme HTML without breaking updates?

Copy the template into a child theme and edit the copy — an edit made in the parent theme through Appearance → Theme File Editor is wiped by the next theme update, and one PHP typo can blank the site. The setup steps are on the WordPress child theme page.

If Theme File Editor is missing from your dashboard, wp-config.php contains DISALLOW_FILE_EDIT or your user role cannot edit themes — treat that as a lock, not a fault. The files themselves live under wp-content/themes/ inside the child theme's folder: download, edit locally, upload under the same filename, then view a page that uses that template. Work after a backup, or on staging.

These edits run on the host that already serves your site. If the site is moving to WebJi®, start at WordPress hosting and wait for migration approval before touching theme files.

Why does WordPress strip some of your HTML?

WordPress filters post HTML through its kses sanitiser on save unless your user has the unfiltered_html capability — which on a single site only Administrators hold. Editors, Authors and Contributors lose script, iframe, form, style and inline event attributes the moment they click Update.

  • Single site: Administrators keep the tags; every lower role loses them.
  • Multisite: a site Administrator does not have unfiltered_html either — only the Super Admin does.
  • The trap: the Custom HTML block can look correct while you type, then the saved post drops the tag. View the page logged out to see what was really stored.

This is not a cache problem: a private window still shows the stripped page because the tag never reached the database.

What do you do if an HTML edit breaks the site?

Undo an invalid block before you click Update; if the public page is already wrong, restore the wp: comments you deleted or roll back through the page's Revisions panel. Do not keep saving over the damage.

  1. White screen after a theme file edit: stop saving. Open the hosting file manager and put the previous template back from your backup.
  2. No backup: rename the active theme folder under wp-content/themes/; WordPress falls back to a default theme and the dashboard returns.
  3. Still stuck: email support@webji.services with the file name and the exact error text — staffed 24/7 in Hindi and English.
FAQ

Frequently asked questions

How do I edit the HTML of a WordPress page?

Open the page, choose Edit as HTML on one block or Code editor for the whole page, then click Update. Check the public URL in a private window so a cached copy does not hide the result.

Where is the HTML editor in the Gutenberg block editor?

Select the block, open its three-dot menu and choose Edit as HTML. For the entire page, open the three-dot Options menu at the top right and switch to Code editor. Both show the same markup at different scope.

Can I paste raw HTML into WordPress posts?

Yes — into a Custom HTML block or the Code editor, not a paragraph block. Paste only the fragment: html, head and body tags from a full document do not belong in a post and will be mangled.

Why did WordPress strip or break my HTML?

Users without the unfiltered_html capability lose script, iframe, form and style tags on save. Single-site Administrators keep them; on Multisite only a Super Admin does. The tag was never stored, so no cache clear brings it back.

How do I edit my theme's HTML without losing it on update?

Copy the template into a child theme and edit that copy. A parent-theme update replaces any file you changed inside the parent, which is exactly why the Theme File Editor on the parent is the wrong place to work.

Last editorial update: 15 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.