Transferred from: http://www.sealog.info/?post=3
Yesterday, a friend of the group asked the page at the top of a blank line can not be removed solution. Common solutions do not solve the problem. In-depth study of the next, summed up a few to strengthen memory.
The margin is not set correctly using margin, margin refers to a blank length that controls the distance between the contents of the container and the edge of the container.
View SourcePrint?
Second, human negligence, especially in the script language source code in a line of blank, the solution is naturally deleted blank line OK.
For the browser, the source code in the return character does not explain the output, but occasionally also appear in the source code to cause the display page is also wrapped problem (Linux and Windows of the carriage return in the file encoding is different), this issue should pay attention to the normative code.
third, the problem of coding. software such as Windows-brought Notepad, when saving a UTF-8 encoded file, inserts three invisible characters (_0xef _0xbb _0xbf, Bom--byte Order Mark) where the file begins. It is a string of hidden characters that allows editors such as Notepad to identify whether the file is encoded in UTF-8. For general files, this does not cause any trouble. but for PHP, PHP at design time does not consider the problem of the BOM, do not ignore the UTF-8 encoded file at the beginning of the BOM three characters, will be the BOM as part of the text at the beginning of the file. because it must be in <? or the code behind the <?php will be executed as PHP code, so it will result in the output of the three characters on the page, the display effect is to see the browser, is usually a blank line or a garbled character. Because of the existence of these 3 characters at the beginning of the HTML, even if the top padding of the page is set to 0, the entire page cannot be kept close to the top of the browser. In addition to this problem can make the webpage inexplicable a line of blank , due to the restrictions of the cookie sending mechanism, in these files have a BOM at the beginning of the file, the cookie cannot be sent out (because the cookie is sent before the file header), so the login and logout function is invalid. All the functions that rely on cookies and session implementations are not valid. Workaround: when editing or changing any text file, be sure to use an editor that does not mess with the BOM. The editor under Linux should not have this problem. Under Windows, do not use editors such as Notepad. The recommended editor is: EditPlus 2.12 or above, EmEditor, UltraEdit (need to cancel the "Add BOM" option), Dreamweaver (need to cancel the ' Add BOM ' related options); Notepad (requires " Conversion to UTF-8 without BOM "). For a file that has already been added to the BOM, you can save it with the above editor if you want to cancel it. (EditPlus needs to be saved as GB first and then saved as UTF-8.) )
Four, the impact of JS code . In the Web page some ads introduced JS or some of the output of the JS code, may cause the top of the page blank problem. The solution is to take turns to remove the JS method to find the problematic JS code, and then modify.
v. the effects of special characters. Copying and pasting text (especially when pasting from word) may have some special characters causing errors in the browser display, such as copyright characters, which should be used in HTML code © To show that if you paste the symbol directly in the source code, there will be problems, the same problem will have space, and so on.
Six, the script language function existence problem . It is possible that the function in the program which class unintentionally output the error, this error to check the code.