ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

HTML line break spacing

(1/1)

flib:
I'm having a really dumb issue and I've just about exhausted my ability to search for an answer.
Here's a basic example of the problem. It really seems like there ought to be some way to fix this with CSS:

--- ---<p>Hello w
orld</p>Outputs

--- ---Hello w orldRather than

--- ---Hello world
This happens because there is a linebreak between 'w' and 'world'. This is mostly an issue because this also happens with images and I would rather that it didn't.

Renegade:
It would be wrong to fix that with CSS. Line breaks serve 2 purposes: 1) Content, 2) Code Formatting. So, there's no way to determine whether the line break is one or the other there. As such, it's interpreted as a space in those cases.

e.g.


--- Code: HTML ---<p> This isa paragraph. And it has 2 sentences.</p><pre>But this is preformattedtextanddisplays asyou see it here.</pre>
I'm not sure if my spaces at the ends of the lines will be rendered here. (Most lines have no spaces.)

Try using a text editor that doesn't automatically break lines. That should solve the problem.

Renegade:
Also, have a read here:

http://stackoverflow.com/questions/1097006/removing-whitespace-between-html-elements-when-using-line-breaks

That addresses the image issue, though all the solutions are messy.

And check here for the authority:

http://www.w3.org/TR/html4/struct/text.html#line-breaks

flib:
Thanks, float:left; fixed it.

Navigation

[0] Message Index

Go to full version