How Do Line Breaks In Your Html Affect Your Resulting Page's Spacing?
Solution 1:
In the HTML specifications, any number of white space becomes a single white space when displayed.
Doing:
<ahref=""></a><ahref=""></a>
is identical to
<ahref=""></a><ahref=""></a>
Or any number of carriage returns or spaces inbetween.
If you don't have white space, then the two just run into each other. This allows things such as bolding in the middle of a word.
EDIT
Thanks to insertusernamehere, the exact location in the HTML 4.01 specification is at:
http://www.w3.org/TR/html401/struct/text.html#h-9.1
In particular, the part that says:
Note that a sequence of white spaces between words in the source document may result in an entirely different rendered inter-word spacing (except in the case of the PRE element). In particular, user agents should collapse input white space sequences when producing output inter-word space.
Solution 2:
This doesn't technically have anything to do with HTML, which itself is just a way of marking up the page. It's actually the CSS styling that collapses white-space via the white-space
property. That property gives you the following options:
normal - This value directs user agents to collapse sequences of white space, and break lines as necessary to fill line boxes.
pre - This value prevents user agents from collapsing sequences of white space. Lines are only broken at preserved newline characters.
nowrap - This value collapses white space as for 'normal', but suppresses line breaks within text.
pre-wrap - This value prevents user agents from collapsing sequences of white space. Lines are broken at preserved newline characters, and as necessary to fill line boxes.
pre-line - This value directs user agents to collapse sequences of white space. Lines are broken at preserved newline characters, and as necessary to fill line boxes.
By default, it is set to normal. This will cause a browser to collapse any sequence of white-space into a single visible space when rendering the HTML structure. Since line breaks are a form of white-space, they also get collapsed.
Solution 3:
In PHP, much like HTML, a line-break/carriage return is generally just used to make your text more legible. This is so that future code edits are simple an easy to make.
Not sure if this is completely relevant but I've found another post which relates to PHP formatting: PHP Coding style - Best practices
Post a Comment for "How Do Line Breaks In Your Html Affect Your Resulting Page's Spacing?"