How to Switch HTML View in WordPress (Step-by-Step Guide)?

Switching WordPress to HTML view takes about five seconds once you know which menu holds the option. Here are all five routes, from the whole-post Code editor to theme files.

Most people who go looking for “HTML view” in WordPress are chasing one of two very different things. Sometimes they want to see the raw markup of an entire post because something in the layout broke and the visual editor won’t show them where. Other times they only need to drop a snippet — an embed code, a callout box, a tracking pixel — into one spot without touching the rest of the page. WordPress handles those two jobs with separate tools, and the menu names differ depending on which editor your site is running.

Method 1: The Code editor for the whole post (Block Editor)

This flips your entire post or page into raw block markup. Use it when you need to hunt a stray tag somewhere in the body, or when you’re pasting in a large chunk of HTML that would be tedious to rebuild block by block.

  1. Open the post or page in the editor.
  2. Look at the top-right corner of the screen and click the three vertical dots (the options menu).
  3. Choose Code editor from the dropdown.
  4. The canvas switches to plain text and you’ll see the block comments — the <!-- wp:paragraph --> wrappers around your content.
  5. Make your edits.
  6. Go back to the same three-dot menu and switch off Code editor to return to the visual view.

There’s a shortcut that saves a surprising amount of time once it’s in your muscle memory: Ctrl + Shift + Alt + M on Windows, or ⌘ + Shift + Alt + M on a Mac, toggles between the visual editor and the code editor. If you press Shift + Alt + H (Control + Option + H on Mac) you’ll get the full shortcut sheet, which is worth one minute of scrolling.

Two cautions. First, the block comments matter. They’re what tells WordPress “this paragraph is a paragraph, this is a heading, this is a column layout.” Delete one and the block it belonged to can collapse into a “This block contains unexpected or invalid content” message when you switch back. Second, if your content includes a Custom HTML or Shortcode block, keep the wrapper comments intact around it — the markup inside those blocks is yours, but the comments around them belong to WordPress.

Method 2: “Edit as HTML” for a single block

This is the surgical option, and it’s the one most people actually need. It exposes the HTML of one block while everything else on the page keeps behaving normally.

  1. Click the block you want to change so its toolbar appears.
  2. In that block’s toolbar, click the three-dot icon at the right end.
  3. Select Edit as HTML.
  4. Edit the markup inline. The block turns into a grey code box.
  5. To get the visual formatting controls back, open the same three-dot menu again and choose Edit Visually.

A practical example: you have a paragraph inside a Group block where the last sentence keeps sitting tight against the edge, and you suspect a stray <br> or a nested <span> with an inline width. Instead of rebuilding the whole section, click that one paragraph, choose Edit as HTML, and you’ll usually spot the culprit in about ten seconds.

One caveat worth knowing: the HTML you write inside Edit as HTML has to fit the block’s own structure. If you paste an entire <table> into a Paragraph block’s HTML, WordPress will likely flag it as invalid when you switch back. For genuinely foreign markup, use Method 3 instead.

Method 3: The Custom HTML block

This is the right tool for embed codes, third-party widgets, and hand-built components that don’t map to any core block. The block drops your code exactly where you place it.

  1. Click the + Block Inserter, then search for “HTML.”
  2. Alternatively, in an empty paragraph, type /html and press Enter — this is the fastest route, and it works mid-flow without lifting your hands off the keyboard.
  3. Paste or type your markup into the block.
  4. Click Preview in the block toolbar to see how it renders on the front end without leaving the editor.
  5. Return to edit mode by clicking Edit — the code stays exactly as you left it.

Two things trip people up here. The first is that the editor shows you your code, not the result, unless you hit Preview; if the block looks like a wall of text, that’s normal. The second is permissions. WordPress runs custom HTML through a capability check, and on a multisite network only Super Admins reliably get to keep tags like <iframe> — everyone else can have them silently stripped on save PublishPress. If your YouTube embed vanishes after publishing but appeared fine in Preview, that’s almost always what happened.

Swap to the Custom HTML block whenever you’re pasting code that came from somewhere else. It’s built to hold markup the editor doesn’t understand, and it won’t fight you about it.

Method 4: The Text tab in the Classic Editor

If your site still runs the Classic Editor — either because the Classic Editor plugin is active or because a page builder has taken over the content area — you’ll see two tabs above the toolbar: Visual and Text.

  1. Open the post.
  2. Click the Text tab above the editing area.
  3. You now see the raw HTML of the post body.
  4. Click Visual to go back to WYSIWYG mode.

Here’s the part that catches people: in the Classic Editor, switching from Text back to Visual can reformat your markup. WordPress’s auto-paragraph logic (wpautop) has a long history of adding or removing <p> tags and closing unclosed tags on that round trip, which is why hand-written HTML sometimes looks different after a hop through the Visual tab Classic Editor issue tracker. If you’ve written something delicate — a form, a carefully nested layout — finish it in the Text tab and publish from there rather than clicking Visual to “check” it.

Also, depending on your version, the Classic block inside the Block Editor may no longer offer Edit as HTML in its three-dot menu; that option has moved around in recent releases Gutenberg issue tracker. If it’s missing on your site, use Method 1 to see the block’s markup at document level.

Method 5: Code editor in the Site Editor (templates and template parts)

The Site Editor — the one that edits your theme’s header, footer, and page templates rather than post content — has its own Code editor, and the toggle lives in roughly the same place.

  1. Go to Appearance → Editor.
  2. Open the template or template part you want (Header, Footer, a specific page template).
  3. Open the three-dot options menu at the top right.
  4. Choose Code editor to view the entire template as HTML.
  5. Switch it off when you’re done.

This is where you’d go to inspect why a header’s column widths behave strangely across breakpoints, or to check whether a template part is pulling the right pattern. Be more careful here than in a post: a broken template affects every page that uses it. Duplicate the template first if you’re experimenting.

Method 6: Theme files, when none of the above applies

Some HTML simply doesn’t live in the content. If your footer credit line, a schema block in the <head>, or a hard-coded call-to-action sits in header.php or footer.php, no editor will show it to you.

Options, in order of preference:

  • A child theme plus SFTP — edit header.php or footer.php locally, upload, refresh. This is the safe route, because a fatal syntax error is recoverable by re-uploading the previous file.
  • Appearance → Theme File Editor — exists on many hosts, but a typo here can lock you out of the admin entirely. Take a copy of the file first.
  • A code snippets plugin — reasonable for CSS and PHP additions, and it usually offers a “safe mode” that disables a snippet that breaks the site.

Whichever you pick, back up before you type. The single most common WordPress support ticket in existence is someone who edited functions.php without a copy.

Troubleshooting: when the option isn’t where it should be

What you seeWhat’s usually going on
No three-dot menu at the top rightThe editor is in distraction-free or fullscreen mode. Press the fullscreen toggle to bring the top bar back.
Code editor is greyed out or absentYou’re in a locked template, a pattern that isn’t editable, or your role doesn’t permit it. Check with an administrator account.
“Edit as HTML” missing from a block’s menuNot every block exposes it, and recent releases have changed where it lives for Classic blocks. Use the document-level Code editor instead.
Custom HTML saves but the embed is goneThe unfiltered_html capability stripped it on save. Common on multisite for non–Super Admin accounts Stack Overflow.
HTML works, styling doesn’tYour pasted markup uses class names your theme doesn’t define. Add scoped CSS in the Customizer, Site Editor, or a child theme.
WordPress nags “unexpected or invalid content”A block comment was removed or an outer tag was closed early. Click “Attempt Block Recovery,” then re-check the wrapper comments.
Everything looks fine in the editor but broken liveA caching layer or CDN is serving the old page. Purge the cache before editing further.

One role note that saves a lot of confusion: on a single-site install, Administrators get broad HTML privileges. On multisite, an “Administrator” of an individual site is not the same as a network Super Admin, and the HTML filtering differs accordingly.

FAQS:

Does switching to Code editor break my design? Not by itself — the toggle only changes how the editor displays the same content. Damage happens when the markup inside changes, most often through a deleted block comment or an unclosed tag.

Can I write a whole post in HTML and skip blocks entirely? You can, using Custom HTML blocks, but you lose the block toolbar, pattern library, and a lot of editing convenience. For a long article, Method 1 plus normal blocks is easier to live with.

What’s the difference between Code editor and the Custom HTML block? Code editor shows you the markup WordPress already generated for your blocks. The Custom HTML block is an empty container for markup WordPress did not generate.

Where did the Text tab go? You’re in the Block Editor. There are no Visual/Text tabs there; the equivalent is the Code editor in the options menu. Install the Classic Editor plugin if you genuinely want the old interface back.

Why does Preview in a Custom HTML block look right when the published page doesn’t? Preview renders with your editing account’s permissions. Publishing re-checks capability on save, so a tag can be allowed in preview and stripped on the front end.

Is HTML view available on WordPress.com? Yes, with the same structure: the Custom HTML block is available on paid plans WordPress.com Support, while direct theme file access requires a Business or Commerce plan.

Final Thoughts:

The short answer, if you only remember one thing: three dots at the top right → Code editor for the whole post, three dots on the block → Edit as HTML for one block, and the Custom HTML block (type /html) for code you brought from somewhere else. Those three cover almost every situation, and the keyboard shortcut Ctrl/Cmd + Shift + Alt + M will get you into code view faster than any menu once you’ve used it twice.

Scroll to Top