0

I've been pulling my hair out trying to work out what's happening here. I have some code for a site that has a header in this sort of pattern:

<head>
<title>Page</title>
... other normal head stuff ...
</head>
<body>
... body stuff ...

which is pretty usual. In all browsers this displays properly, except on one page in both Chrome and IE there is a gap appearing at the beginning of the body causing all the content to be pushed down.

I've inspected the code using dev tools in chrome, and it seems to be rearranging the header stuff to look like this:

<head></head>
<body>
"

"
<title>Page</title>
... other normal head stuff ...
... body stuff ....

This " " space is causing linebreaks to be added at the beginning of the page, and the contents of <head> to be moved after <body>. As I say, this is only ONE page it's occurring in in Chrome and IE, which is the confusing part as all pages in the site have the same header file included.

Deleting the " " from within the dev tools corrects the problem, but this is no where in the actual source code.

Why would it be rearranging the contents of <head> and adding that weird extra space? Anyone have any experience with this?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
hashi
  • 77
  • 9
  • Are you using a CMS with any SEO plugins? – Lee Jan 13 '15 at 12:11
  • If you're including the header file, is this using PHP? – Lee Jan 13 '15 at 12:13
  • Yes, included with php. Sorry, should have mentioned :) – hashi Jan 13 '15 at 12:13
  • 3
    Can we see the contents of the head file, and how you're including it - like an example of the homepage and another page where it's not behaving like this? – Lee Jan 13 '15 at 12:14
  • The header file is more or less: http://pastebin.com/VFs9yTFV All my php pages start with: http://pastebin.com/0ybKnpn1 – hashi Jan 13 '15 at 12:18
  • @hashi: that doesn't have a `` nor a DOCTYPE declaration, my guess is that you're triggering quirks mode on one of the pages for some reason. (I think IE devtools can show you if the engine is in quirks or compatibility modes.) – Ulrich Schwarz Jan 13 '15 at 12:40
  • Ohhk, there is an html tag, I guess I must have missed out that out in my copy/paste. I'll have a look into that. – hashi Jan 13 '15 at 12:47
  • Ok I found it. Turns out Chrome and IE don't seem to like it when the editor I'm using saves the document encoded as UTF-8. Thanks guys for the help. – hashi Jan 13 '15 at 12:57
  • 1
    @hashi: If this solves your problem, please add it as an answer (and accept it). – unor Jan 13 '15 at 13:28
  • 1
    Show an actual example of a page that demonstrates the problem, *in the question itself*. Adding a jsfiddle or equivalent is recommendable. – Jukka K. Korpela Jan 13 '15 at 14:11

0 Answers0