0

So, I have the simplest page. Just one div, but I can't get rid of the white gap at the top. I have tried Chrome and IE, same result on both.

HTML:

<?php
    session_start();
    include "./script/db-connect.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no">
<head>
    <title>Test</title>
    <link rel="stylesheet" type="text/css" href="./css/main.css" />
</head>

<body>
    <div id="top_bar">
    </div>

</body>
</html>

CSS:

* { 
    margin: 0; 
    padding: 0; 
    border: none;

}

#top_bar{
    width: 100%;
    height: 70px;
    background-color: #00ff00;
}

SCREENSHOT: Screenshot

EDIT: So, I found it it's the php part which is outputing &#65279 in body. The gap dissapears when I remove the php-script. So, question is, how do I fix it?

PHP:

<?php
$host="localhost";
$user="member";
$pw="";
$db="db";

$link=mysqli_connect($host, $user, $pw, $db) or die("error");
?>
SlyTech404
  • 198
  • 1
  • 11
  • Can you provide a screenshot? – samurai_jane Jan 14 '16 at 01:39
  • I am not able to duplicate the error but I would try inspect element and see if there's something in the structure that accounts for the space. Next I would try eliminating things to narrow down the variables. Maybe also try putting `!important` on your margin and padding. Sorry I cannot offer a more specific solution but I am interested to find out what's causing it when you figure it out so please post what worked for you. – samurai_jane Jan 14 '16 at 01:56
  • @samurai_jane I updated the question – SlyTech404 Jan 14 '16 at 02:04
  • 1
    Looks like it might be a BOM issue. See [here](http://stackoverflow.com/questions/9691771/why-is-65279-appearing-in-my-html) and [here](http://stackoverflow.com/questions/6538203/how-to-avoid-echoing-character-65279-in-php-this-question-also-relates-to-java). – ralph.m Jan 14 '16 at 02:51
  • @ralph.m Thanks for the clue! – SlyTech404 Jan 15 '16 at 15:54

1 Answers1

0

I fixed the problem, thanks to @ralph.m

The problem was that the included php-file: db-connect.php was encoded with BOM.

All I did was set the encoding to UTF-8 without BOM and the gap is now closed

SlyTech404
  • 198
  • 1
  • 11