topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday April 16, 2024, 11:37 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: HTML line break spacing  (Read 3373 times)

flib

  • Participant
  • Joined in 2009
  • *
  • Posts: 9
    • View Profile
    • FlibNet
    • Donate to Member
HTML line break spacing
« on: November 09, 2011, 01:31 AM »
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 orld
Rather 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

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: HTML line break spacing
« Reply #1 on: November 09, 2011, 03:18 AM »
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 [Select]
  1. <p> This is
  2. a paragraph. And it has
  3. 2 sentences.
  4. </p>
  5. <pre>But this is preformatted
  6. text
  7. and
  8. displays
  9. as
  10. you 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.
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: HTML line break spacing
« Reply #2 on: November 09, 2011, 03:21 AM »
Also, have a read here:

http://stackoverflow...en-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...ext.html#line-breaks

Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

flib

  • Participant
  • Joined in 2009
  • *
  • Posts: 9
    • View Profile
    • FlibNet
    • Donate to Member
Re: HTML line break spacing
« Reply #3 on: November 09, 2011, 07:17 AM »
Thanks, float:left; fixed it.