Line Break Weirdness

  • Thread starter Thread starter GilesGuthrie
  • 4 comments
  • 1,586 views

GilesGuthrie

Staff Emeritus
Messages
11,038
United Kingdom
Edinburgh, UK
Messages
CMDRTheDarkLord
Sandstorm alterted me to something odd in the way vB handles lines with lots of formatting in them.

If you enter with no spaces and no line break (for example)
Code:
[ center ][ SIZE=3 ][ color=red ]the[ B ]official[ /B ]gtplanet[ B ]granturismo[ /B ]
real[ B ]driving[ /B ]simulator[ B ]®[ /B ][ /color ][ /SIZE ][ /center ]
(spaces and line break have been added in the code to get the code to display readably and unformatted)

You get
theofficialgtplanetgranturismorealdrivingsimulator®

which should be on one line. This isn't particularly interesting until you look at the html source that vB generates for this line:

Code:
<div align="center"><font size="3"><font color="red">the<b>officia<br />
l</b>gtplanet<b>granturismo</b>real<b>driving</b>simulator<b>®</b></font></font></div>

The interesting thing here is the <br /> tag. I've never actually seen this tag before, always just using <br> to force a new line break.

Although, having checked my own forums, this form of tag does appear to be the one used when PHP converts a line break in a string into a line break in HTML (PHP coders would use echo nl2br($string); to do this).

So...

It appears that in certain circumstances, there is a maximum length for a single word (i.e no spaces) in the database. I can verify this, because deleting characters before the line break shifts the line break along by the number of characters that you deleted.

Is this something that's been mentioned before? Is it intended? And if not, do you think it's something that the vB programmers would be interested in?
 
This is indeed a strange problem. I've tried going in manually and rectifying it through the "view source" option in the right-click menu, but it doesn't seem to work, and I can't think of any other way to fix the problem.

Any help would be greatly appreciated.

:cheers:
 
<br> and <br /> mean the same thing, but the latter is what gets used for XHTML 1.0 standards.

The XHTML standards dictate that every tag has an start and end tag (end tags have a "/" in front of them). An example is <title> ...and... </title>

However, there's also 4 or 5 tags that don't have any corresponding end tag: <link> <img> <br> <meta>, etc. To make the standards fit, the <"HTML TAG" /> was created to denote it had no end tag.

Incidently, there is only exception to the end tag rule:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> doesn't get one...some sort of XML thing, I suppose.

Somehow, the <br /> thing isn't understood by the parser because it's rather new (early 2001?), and HTML 4.0 hasn't changed in about 5 years.

* I can't believe that I answered a programming question.
 
I'm really not sure why that happens, nor am I sure if it is intended or not (I predict that it is so that a user can not type a long string of text to force the width of a page to be wider. However, this effect still occurs quite frequently, so I doubt this is true.) I will ask the vB developers and see what they have to say about it.
 
Back