Header has extra HTML block at top before my code

I’ve been trying to fix the issue where wp_head loads in the body tag in wordpress, and I’ve discovered that when I look at the page source, an extra HTML block appears before the code from my header.php file.

Here’s what I’ve tried:

  1. Setting wp_debug to true
  2. ensuring that charset is UTF-8
  3. removing all text before the beginning of !DOCTYPE
  4. check for missing closing tags

This is my header.php file
enter image description here

Here is the output source:
You can see that my code is being rendered correctly.. but why am I getting a HTML block at the start of the document??

You can see that my code is being rendered correctly.. but why am I getting a HTML block at the start of the document?? Any help would be amazing. Thanks so much

1 Answer
1

I am really not sure what’s causing this. Can you try with a minimal content in header.php? Something like this and see if the problem occurs?

<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>  

And, meta tags doesn’t support class attributes like you have in line 11.

Leave a Comment