starbeamrainbowlabs
starbeamrainbowlabs

Reputation: 6106

H1 extra whitespace

I have a php file on my test server, and it outputs the following: enter image description here

There is some extra white space on the page, highlighted by the red box. Dev tools view: enter image description here The extra whitespace is highlighted in the dev tools. File that is outputted: enter image description here As you can see, all of the file is on one line.

Code:

<?php
    header("Content-Type: text/html; charset=utf-8");
    if(!isset($_GET['action']))
    {
        $_GET['action'] = "home";
    }

echo("<!DOCTYPE HTML>");
    echo("<html>");
        echo("<head>");
            echo("<title>Bug Tracker -  ");
            echo($_GET['action']);
            echo("</title>");
            echo('<link rel="stylesheet" href="common.css" />');
        echo("</head>");
        echo('<body>');
            require("action.php"); 
        echo("</body>");
    echo("</html>")
?>

This happens in firefox as well.

Upvotes: 2

Views: 7704

Answers (4)

auslentz
auslentz

Reputation: 31

In my CSS, setting the h1 margin to 0 fixed it for me.

CSS:

h1 {
    margin:0;
}

Upvotes: 1

ddoor
ddoor

Reputation: 5963

You need to be more clear in what you want.

The white space in your browser is most likely due to action.php having white space in it. White space is only created because php prints HTML (or similar) to the browser. Remember that PHP runs server-side, so the browser doesn't actually download the php file, it only reads the HTML.

Check (or show us) your action.php file

Also try

echo "<h1 style='vertical-align:text-top;'>Bug tracker home page</h1>";

~ Dan

Upvotes: 0

Simone
Simone

Reputation: 21262

<h1> tag usually has a default margin. Try to set h1 { margin:0 } in your CSS.

Upvotes: 5

Camrin Parnell
Camrin Parnell

Reputation: 449

I believe a h1 tag always has margin top and bottom that is why you are seeing the white space. If you add a margin-top: 0 to the h1 then it will remove the space above.

Upvotes: 3

Related Questions