View Single Post
Old 05-19-2015, 08:01 PM   #22
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by chaley View Post
Try the following html
Code:
<html>
<body>
<font color="red">hi</font>
<font color="green">there</font>
</body>
</html>
At least on Chrome you will see that there is a space between "hi" and "there". Clearly the return is not being ignored but is instead converted to white space even though it is "between tags". That space will not be there if there is no return after the first </font>. If a pretty printer adds such a return then it changes the output.

I found HTML rules for white space to be fiendishly complicated. They are dependent on the rendering engine and the semantics of the tags surrounding the white space. My experience is that if the tag does not generate white space on its own (<p> does) then one may or may not see the white space implied by the returns.
As I understand it, whitespace (including the EOL character) is collapsed into one standard space within a block-level tag, and is ignored entirely if outside a block-level tag.

<p> is a block-level tag, and whitespace after a </p> and before a </body> is ignored, but <font> is an inline tag and spaces appear (collapsed) just like they do between words of plain text, or separated using span,em,b,i,strong, etc.

Your example has inline tags floating in a raw <body>, so I think the parser just throws up its hands and pretends there is a div or something there, but note that
Code:
<html>
<body>
<font color="red">hi</font>
<font color="green">there</font>
       
</body>
</html>
displays none of the linebreak + 7 spaces I inserted.


As for <p> generating its own linebreak, it only defines a content block, and block-level tags are separated from other block-level tags by a linebreak.
eschwartz is offline   Reply With Quote