zaedas99
zaedas99

Reputation: 50

Random white space in body element

I've sumbled upon a problem that never occured before : A white space ( " " ) in the body element.

Obviously, that little thing is screwing with the whole layout, and on top of it, it's actually dumping the head's code into the body.

I.E :

Instead of having this (when the browser render the page):

<html>
    <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0" />

            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
            <script src="http://code.highcharts.com/highcharts.js"></script>
            <script src="http://code.highcharts.com/modules/exporting.js"></script>
            <script src="Scripts/json2.js"></script>

            <!-- Stylesheets -->
            <link rel="stylesheet" type="text/css"
            href="css/desktop.css" />
...
</head>

I have this :

<html>
    <head></head>
<body>
" " <!-- Here's the problem! -->
<! --Entire metas, scripts and whatnot is going here, too. 
Probably because of that white space! -->

I am literally puzzled as to what is causing the problem... I have been on the web for the past two hours, looking for every single link on google and stack overflow without much success...

Most suggestions that i found (but did not help me) were the following :

If anybody have a suggestion as to how to fix this, i'd be grateful. Sadly, this is not my project, so i have limited capabilities to troubleshoot what's going on / cannot revert to an older state.

Also, there's no css involved in this (this is no mere padding or anything).

Here's a screenshot showing the problem :

Here's a pastebin of the raw content :

http://pastebin.com/tQthe5pv

Update : The source now has no whitespace before the doctype and is still doing the problem.

Upvotes: 2

Views: 2599

Answers (3)

fboes
fboes

Reputation: 2239

Try to validate your HTML. For your local version http://validator.w3.org/#validate_by_input may help you.

If your code is valid, try to disable the Javascripts on your page one by one. Maybe some DOM-voodoo keeps messing up your code after loading the page.

Update: After getting the original code from http://pastebin.com/tQthe5pv, I can reproduce your error. By deleting all (whitespace-)characters before "<!DOCTYPE html>" the error was fixed. :)

Upvotes: 1

zaedas99
zaedas99

Reputation: 50

This was a weird one, but here we go:

After troubleshooting for several hours at my job, i managed to isolate the problem. It was coming from a file named "database.php".

Apparently, each time a call was made to the database, some kind of illegal caracter was created inside the file (maybe due to bad encoding? I don't know, i'm pretty sure i encoded the file in utf-8 without bom, but whatever).

I fixed the problem by starting from scratch and copying every single line by hand. I haven't encountered the problem since.

Upvotes: 0

Raidri
Raidri

Reputation: 17550

Updated:

There is some whitespace(?) before the <!DOCTYPE html> at the start of the file. After removing this Chrome showed the correct page structure.

Also, but not the source of the error: According to your pastebin, the following tag is not closed:

<link href='http://fonts.googleapis.com/css?family=Anaheim' rel='stylesheet' type='text/css'>

Upvotes: 1

Related Questions