Home  >  Article  >  Web Front-end  >  Reasons and solutions for the existence of whitespace characters between html tags under IE6 and 7, resulting in unnecessary white space occupied after rendering_html/css_WEB-ITnose

Reasons and solutions for the existence of whitespace characters between html tags under IE6 and 7, resulting in unnecessary white space occupied after rendering_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:47:011091browse

Directly above:


Reason: The content contained in this div is printed and output in the background. If nothing is output, the browser will add whitespace to the empty area by default.
Under IE6 and 7, when the browser parses and renders, it will consider that whitespace characters also occupy space. By default, they have font attributes, so the "excess space-occupying" bug will appear.

Solution:

1. Let the html tags be connected and output. For example:

. ??It’s too cumbersome, the code is irregular, and it’s difficult to maintain.

2. Set font-size:0; ??Can’t be a perfect fix~

2. Use the comment character . For example:

, so that there is no white space in the middle of the div. ​??Although this can fix the problem, it is not good enough

3. Use the tag. For example:

. ??In this way, the browser will not automatically add blank characters to the tag content, and no redundant information will be displayed on the page. It is a perfect solution~

Additional knowledge:

wbr tag: It functions as a soft line break. The browser will automatically break the text content according to the width of the container

Compatibility:

View URL: http://www.quirksmode.org/oddsandends/wbr.html

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn