PHP include causes white space at the top of the page

后端 未结 15 1108
無奈伤痛
無奈伤痛 2020-11-30 09:36

I have a problem on a site that I am making. There is this line of white space at the top of my page. I can not find out where it is coming from. It might be because of extr

相关标签:
15条回答
  • 2020-11-30 10:06

    After you declare a DOCTYPE make sure to add CSS reset into the first line of your CSS code to make it consistent across all browsers :

    *{margin:0;
     padding:0;
     }
    
    0 讨论(0)
  • 2020-11-30 10:07

    Important: If you have multiple php pages as I have in my website using utf-8, you need to make sure you change the encoding of every single page to be "Encode in utf-8 without a BOM".

    0 讨论(0)
  • 2020-11-30 10:08
    1. Open file in Notepadd++

    2. From top bar: Encoding->Encode in UTF8 without BOM

    3. Save the file

    In Dreamweaver

    Press CTRL + J or go to Change->Page Settings->Tile/Encoding and unchek UNICODE BOM if it is cheked.

    0 讨论(0)
  • 2020-11-30 10:09

    Yep, there's extra whitespace included before anything else.

    May I recommend the use of output buffering to you? You will gain a fine grained control of what is pushed to the client.

    0 讨论(0)
  • 2020-11-30 10:16

    For some reason after your body tag before the first div you have some funky character... just delete them and re-indent as needed. the character  to be precise... (you can see it in Firebug if you inspect the HTML for the page...but you can't see it in the view-source because it renders as whitespace).

    unrelated to the alignment issue... you also have a miss-matched closing </li> tag after your login/signup link.

    0 讨论(0)
  • 2020-11-30 10:17

    I got it! I must admit, this was a very strange one.

    This was my exact problem, and his solution fixed it perfectly.


    The problem was because of the include().

    When you save a page as UTF-8, a special signature called a byte-order mark (or BOM) is included at the beginning of the file, indicating that it is a UTF-8 file. You can only see BOMs with low level text editors (such as DOS edit). You need to remove this signature from the included file in order to get rid of the white space at the top of the page.

    DOS edit

    0 讨论(0)
提交回复
热议问题