{"id":1322,"date":"2006-06-03T16:33:55","date_gmt":"2006-06-03T11:03:55","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/"},"modified":"2026-10-21T15:17:39","modified_gmt":"2026-10-21T09:47:39","slug":"fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/","title":{"rendered":"How to Fix Unclosed HTML Tags in WordPress Posts (2026)"},"content":{"rendered":"<p>Has your sidebar suddenly dropped below your content, or does half a page show up in giant heading text? The usual cause is <strong>unclosed HTML tags in WordPress<\/strong>: a <code>&lt;div&gt;<\/code>, <code>&lt;h2&gt;<\/code> or <code>&lt;strong&gt;<\/code> that was opened in a post but never closed. I ran into this in 2006 after moving QuickOnlineTips from Blogger to WordPress. Here&#8217;s why it happens, how to find the broken post, and how to fix it in today&#8217;s block editor and Classic Editor.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-67789\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026.webp\" alt=\"Fixing unclosed HTML tags in WordPress code\" width=\"1200\" height=\"630\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026.webp 1200w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026-300x158.webp 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026-1024x538.webp 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026-150x79.webp 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/unclosed-html-tags-wordpress-2026-768x403.webp 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><strong>Quick answer:<\/strong> To fix unclosed HTML tags in WordPress, open the broken post, switch the block to Edit as HTML (or use the Code editor with Ctrl+Shift+Alt+M), and close or remove the stray tag. Find the culprit by viewing the page source or running it through the W3C Markup Validator. In the block editor, an &#8220;unexpected or invalid content&#8221; warning often points straight to the broken block.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_90 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6b03693c1a483\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6b03693c1a483\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#What_went_wrong_on_my_blog\" >What went wrong on my blog<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#Why_unclosed_HTML_tags_still_happen_in_2026\" >Why unclosed HTML tags still happen in 2026<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#How_to_find_the_broken_post\" >How to find the broken post<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#How_to_fix_unclosed_HTML_tags_in_WordPress\" >How to fix unclosed HTML tags in WordPress<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#In_the_block_editor_Gutenberg\" >In the block editor (Gutenberg)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#In_the_Classic_Editor\" >In the Classic Editor<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#Lessons_that_still_apply\" >Lessons that still apply<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#FAQ\" >FAQ<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#Why_is_my_WordPress_sidebar_showing_below_the_content\" >Why is my WordPress sidebar showing below the content?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#Does_WordPress_close_HTML_tags_automatically\" >Does WordPress close HTML tags automatically?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#How_do_I_see_the_HTML_of_a_WordPress_post\" >How do I see the HTML of a WordPress post?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2006\/06\/fixing-errors-by-unclosed-tags-in-wordpress-visual-text-editor\/#What_does_%E2%80%9CThis_block_contains_unexpected_or_invalid_content%E2%80%9D_mean\" >What does &#8220;This block contains unexpected or invalid content&#8221; mean?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_went_wrong_on_my_blog\"><\/span>What went wrong on my blog<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>After importing my posts and comments from Blogger, I went through hundreds of posts fixing lost formatting and broken internal links. To speed up editing, I used a plugin that hid the post preview. That was my mistake. Blogger&#8217;s editor closed tags automatically or warned about them, but WordPress happily published posts with unclosed tags. Some stray <code>&lt;div&gt;<\/code> and <code>&lt;h2&gt;<\/code> tags, possibly left over from the import, slipped through.<\/p>\n<p>The result: broken page templates and distorted fonts. An unclosed <code>&lt;div&gt;<\/code> can push your sidebar under the content in a CSS layout, and an unclosed heading tag can turn the rest of the page into heading-sized text.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_unclosed_HTML_tags_still_happen_in_2026\"><\/span>Why unclosed HTML tags still happen in 2026<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Custom HTML blocks<\/strong> or &#8220;Edit as HTML&#8221; changes with a missing closing tag.<\/li>\n<li><strong>Pasting from other websites or Word<\/strong>, which brings hidden markup with it.<\/li>\n<li><strong>Old posts from the Classic Editor<\/strong> or imports from Blogger and other platforms.<\/li>\n<li><strong>Shortcodes and ad code<\/strong> pasted into posts that open a tag but don&#8217;t close it.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_to_find_the_broken_post\"><\/span>How to find the broken post<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li><strong>Check where the layout breaks.<\/strong> If it only breaks on one post, that post is the culprit. If it breaks on your home page or an archive, look at the posts shown just above the break.<\/li>\n<li><strong>Look for block warnings.<\/strong> The block editor shows &#8220;This block contains unexpected or invalid content&#8221; when markup doesn&#8217;t match what it expects. Click <strong>Attempt recovery<\/strong> or open it as HTML.<\/li>\n<li><strong>Validate the page.<\/strong> Paste the post URL into the <a href=\"https:\/\/validator.w3.org\/\" target=\"_blank\" rel=\"noopener\">W3C Markup Validation Service<\/a>; it lists unclosed elements with line numbers.<\/li>\n<li><strong>Use browser developer tools.<\/strong> Right-click the broken area and choose <strong>Inspect<\/strong> to see where an element unexpectedly wraps the rest of the page.<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"How_to_fix_unclosed_HTML_tags_in_WordPress\"><\/span>How to fix unclosed HTML tags in WordPress<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"In_the_block_editor_Gutenberg\"><\/span>In the block editor (Gutenberg)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Select the block, open the three-dot menu and choose <strong>Edit as HTML<\/strong>. Add the missing closing tag or delete the stray opening tag.<\/li>\n<li>For the whole post, open the <strong>Code editor<\/strong> from the Options menu (Ctrl+Shift+Alt+M on Windows, Cmd+Shift+Option+M on Mac).<\/li>\n<li>Convert an old Classic block to blocks (<strong>Convert to blocks<\/strong>). The editor often cleans up messy markup during the conversion.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"In_the_Classic_Editor\"><\/span>In the Classic Editor<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Switch to the <strong>Text<\/strong> tab and find the stray tag. Back in 2006 my advice was to write in the text editor and use its &#8220;Close tags&#8221; button before publishing, and the Text tab still gives you that control today.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Lessons_that_still_apply\"><\/span>Lessons that still apply<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li><strong>Always preview before publishing.<\/strong> WordPress preview shows the whole page, including the header, sidebar and footer, so layout problems are easy to spot.<\/li>\n<li><strong>Paste as plain text.<\/strong> Use Ctrl+Shift+V (Cmd+Shift+V on Mac) to paste without formatting, or paste into a plain text editor first. Copied HTML can bring its own classes and tags into your theme.<\/li>\n<li><strong>Do regular quality checks.<\/strong> Skim your archives after big edits or imports, and fix <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2020\/04\/find-remove-internal-broken-links\/\">broken internal links<\/a> at the same time.<\/li>\n<li><strong>Keep backups and revisions.<\/strong> In 2006 long posts sometimes vanished in the editor and I kept copies in a text file. Today WordPress autosaves and keeps revisions, so you can restore an earlier version from the <strong>Revisions<\/strong> panel.<\/li>\n<\/ol>\n<p>If your theme styles break only inside the editor, see how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2020\/02\/add-custom-css-wordpress-post-editor\/\">add custom CSS to the WordPress editor<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"FAQ\"><\/span>FAQ<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Why_is_my_WordPress_sidebar_showing_below_the_content\"><\/span>Why is my WordPress sidebar showing below the content?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Usually an unclosed or extra <code>&lt;div&gt;<\/code> in a post or widget. Find the post shown just before the break and fix its HTML.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Does_WordPress_close_HTML_tags_automatically\"><\/span>Does WordPress close HTML tags automatically?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Partly. WordPress and browsers try to balance tags, but they can&#8217;t always guess your intent, so broken markup can still affect the layout.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_I_see_the_HTML_of_a_WordPress_post\"><\/span>How do I see the HTML of a WordPress post?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In the block editor, open the Options menu and choose Code editor, or choose Edit as HTML on a single block. In the Classic Editor, click the Text tab.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_does_%E2%80%9CThis_block_contains_unexpected_or_invalid_content%E2%80%9D_mean\"><\/span>What does &#8220;This block contains unexpected or invalid content&#8221; mean?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The block&#8217;s saved HTML doesn&#8217;t match what the editor expects, often because it was edited by hand. Use Attempt recovery or fix the HTML.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Has your sidebar suddenly dropped below your content, or does half a page show up in giant heading text? The&#8230;<\/p>\n","protected":false},"author":4,"featured_media":67789,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6,36],"tags":[17],"class_list":["post-1322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","category-about","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/1322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=1322"}],"version-history":[{"count":2,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/1322\/revisions"}],"predecessor-version":[{"id":67798,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/1322\/revisions\/67798"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/67789"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=1322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=1322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=1322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}