Ignore Whitespace in HTML
In HTML, whitespace between elements can create unwanted spaces in the rendered output. To address this, this question explores solutions to make the browser ignore whitespace.
The answer suggests using the CSS property white-space-collapse: discard;. However, it notes that this feature is not yet implemented in any browser. As an alternative, the answer suggests using HTML comments to hide the whitespace, resulting in a more readable code structure.
Example:
#parent_of_imgs { white-space-collapse: discard; } <!-- This feature is not yet implemented in any browser --> <!-- Using comments as an alternative --> <p> <!-- This is a comment --> <img src="." alt="" /> <!-- This is a comment --> <img src="." alt="" /> <!-- This is a comment --> <img src="." alt="" /> <!-- This is a comment --> <img src="." alt="" /> <!-- This is a comment --> </p>
The above is the detailed content of How Can I Make Browsers Ignore Whitespace in HTML?. For more information, please follow other related articles on the PHP Chinese website!