I have some problem with my HTML code but I cannot figure out why, hope you guys can help me.

My website here although displayed fine, I saw some problem when I use Firebug to detect the code. This is how it displayed in Firebug dock:

<html lang="en-US">
<head> </head>  ******THIS IS WHERE THE STRANGE THING HAPPEN*******
<body>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <title>Cây cảnh</title>
    <meta content="Purple Tree Farm, Tennessee, farmers market, Murfreesboro, Franklin, Shelbyville, seasonal plants, Bedford County, hanging baskets, potted herbs, vegetable slips, greenhouses" name="keywords">
    <meta content="Loca....
    ....

</body>

Strange thing is the meta, title, link, script tags stay in body instead of head tag.
I could not fine any problem with the code generated by Wordpress when I use View page source function (Firefox) to observe the codes.

Please help me find out why those tags does not stay in head as normal

You can see my code index.php, footer.php, header.php to see how I linked all of them with this link:

Thanks all of you for your help

Dani AI

Generated

Short expert addendum:

This is a common symptom: the DOM inspector shows meta/title/link/script nodes under the body while "View page source" looks fine. In this thread the root cause was a duplicate header include — thanks to for spotting that and to for the tip about hidden-copy artifacts. confirmed removing the extra include fixed it.

Why that happens: WordPress themes expect header.php to output the document start and for plugins/core to inject head content via the wp_head() hook. If the header template is included a second time (or included after the template has already opened the body), any head output from that second include — or from hooks — will appear inside the body in the parsed DOM. Also note that browser inspectors show the browser’s corrected DOM, not the raw server HTML; that explains why the inspector and "View Source" can differ.

Practical checklist to prevent/diagnose this:

  • Check the raw server output with View Page Source or a fetch tool to see the actual order of tags.
  • Search your theme files for duplicate header includes and remove extras; get_header should only be called from templates, not from header.php itself.
  • Ensure header.php outputs the opening HTML/head and calls wp_head() once before the head closes; ensure footer.php calls wp_footer() before the closing body tag.
  • Look for invisible BOM or stray characters at the top of PHP files if the doctype/doctype placement seems wrong.
  • Enqueue scripts/styles with WordPress APIs and move noncritical JS to the footer rather than hardcoding tags.

Following that checklist will stop head elements from surfacing inside the body and avoids confusing inspector output. If it reoccurs, disable plugins and switch to a default theme to isolate the source.

Recommended Answers

All 3 Replies

I had this problem once after I had copied and pasted the header with the doctype from another page. It was picking up something weird that I couldn't see in the editor that somehow got copied over.

Go into your header.php and manually remove <!DOCTYPE html> and then retype it again.

You had two calls to <?php get_header(); ?> once in Index.PHP and again in Header.PHP which may have been the cause. Here are your files. I removed the js from the header and placed in footer to speed up page loading. If it doesn't fix your issue let me know and I will see what I can do.

Hi and , I try both of your ways and removing <?php get_header(); ?> in Header.PHP did work, somehow I did not see the code there.

Thank all of you for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.