PDA

View Full Version : New line affecting markup



scrappy
Jun 26th, 2009, 06:28 PM
For some reason, I always assumed that HTML pretty much ignored whitespace and carriage returns between tags unless in a <pre> or <textarea>. However:

<span class="box">Woof</span><span class="box">Woof</span>

renders as:
http://titsfost.googlepages.com/ww1.png

whilst:

<span class="box">Woof</span>
<span class="box">Woof</span>

renders as:
http://titsfost.googlepages.com/ww2.png

So there will be about 20 span's on the one line, I'd like to use a carriage return in the editor rather than having everything in one long line and using the scroll bar.

Apostropartheid
Jun 26th, 2009, 06:35 PM
That's because there is now a space in between the elements (there is one at the end of the first line.) Because spans (note the lack of apostrophe) are inline elements, a space counts as a gap between them. I'm afraid you're just going to have to either delete the space, or, if that doesn't solve it, live with it.

scrappy
Jun 26th, 2009, 06:39 PM
I'll be quite happy if I know the space is consistant. Since I'll have a number of spans on the line, can I assume that a standard single space (not &nbsp;) will be the same width as a newline on most browsers?

abduraooft
Jun 26th, 2009, 06:41 PM
So there will be about 20 span's on the one line, I'd like to use a carriage return in the editor rather than having everything in one long line and using the scroll bar. Try

<span class="box">Woof</span><span
class="box">Woof</span><span
class="box">Woof</span>

scrappy
Jun 26th, 2009, 07:02 PM
:D I like your style!