HTML head-tag get broken in my child theme

I created a child theme from twentythirteen and it worked like it should. Then I made a copy of the parent theme’s header.php. As soon as I created it, the outputted HTML got broken. All tags that are supposed to go in the <head>-tag instead shows up in the <body>-tag, and the <head> is empty. This happens even if the content of header.php in my child theme is exactly the same as the original.

The same happens if I create a new functions.php in my child theme. Even though it only contains this:

<?php
?>

or is totally empty. If I remove the file, the head content get put in the correct place again.

EDIT: The actual source code is actually correct (if I choose “view source”), the error only shows up in inspector mode in Chrome and IE, but not in Firefox’s inspector.

1 Answer
1

I used to have this problem once, for me it happened because I used the wrong encoding. I also had the right sourcecode but it came out all wrong on the actual page.

Try setting your editors settings to “UTF-8 without BOM” because the BOM is what seems to be causing that error.

Sometimes it also happens if you copy and paste text from somewhere and it copies some invisible characters. Try typing the stuff yourself, and it might just work.

(there’s more people with the same problem, e.g.
https://stackoverflow.com/questions/17566119/why-are-tag-title-meta-tag-going-from-head-to-body-tag-automatically

https://stackoverflow.com/questions/14646223/header-appearing-in-body-tag-wordpress
and what I said above usually worked for them to fix it)

Leave a Comment