View Full Version : The BR tag
tommyxv
05-24-2006, 02:41 AM
When I make changes to my template i sometimes use
<br>
and not <br />
What problems will it cause?
hambil
05-24-2006, 07:10 AM
It's not well formed. Some browsers and other tools could have problems with it, causing the page not to display properly, or the tool not to work as expected.
tommyxv
05-24-2006, 07:58 AM
Thats what i figured. My footer would be bunched up and be on top of the posts in a thread sometimes in FF. I had a many
<br> and not <br />
in the footer. I changed them so hopefully it will fix the problem.
Thanks,
firstrebel
05-24-2006, 12:15 PM
Normally most tags need to be closed, such as <p></p>, but the br tag is one of a few that has never need to be closed, that is why most have always used <br>. With things moving on, especially with XHTML you should close all tags, so this should be <br />. It is also a good idea to close all other similar tags by putting a space then /> after the tag name. For example with the img tag - <img src="graphics/v8_engine.gif" alt="Animated V8 engine" width="90" height="90" border="0" align="left" />
Bob
Zachery
05-24-2006, 12:48 PM
Normally most tags need to be closed, such as <p></p>, but the br tag is one of a few that has never need to be closed, that is why most have always used <br>. With things moving on, especially with XHTML you should close all tags, so this should be <br />. It is also a good idea to close all other similar tags by putting a space then /> after the tag name. For example with the img tag - <img src="graphics/v8_engine.gif" alt="Animated V8 engine" width="90" height="90" border="0" align="left" />
Bob
Its not normally bob, its in Older versions of HTML tags were abit less well defined.
In HTML 4 and such, not all tags that were opened needed to be closed.
<br> for examle is a prefectly valid tag in html 4, as well as <img src="">
<table>
<tr>
<td>
<td>
<td>
<td>
</tr>
</table>
I believe is valid in html3 and possibly also 4. XHTML came around and it made lots of changes to how things should and should not be done in the code, it was alot of standarization. All tags are lower case, all tags must be opened and closed. Some tags must have additional attirbutes.
So, <br> becomes <br /> and <img src=""> becomes <img src="" alt="" />. Tables get more strict too as well as deprecated.
<table>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Not to mention tons of times in less well coded html people would use the <p> tag like it was a br tag and thats also not accectable. :)
hambil
05-24-2006, 10:40 PM
I hate the space before the />
<br /> just annoys me. I always use <br/>. I have no idea why someone decided the 'standard' was to stick a space in there, and I'd like to find them and do bad things to them.
Zachery
05-25-2006, 02:51 AM
< start tag
br start tag type
spacing
/> end tag, if there is no space its not valid as the tag is recognized as br/ not br
Adrian Schneider
05-25-2006, 02:56 AM
<br> is HTML and <br /> is XHTML.
vBulletin is set to use XHTML Transitional by default, so to keep things consistent, use <br />.
tommyxv
05-25-2006, 03:55 AM
I had a few <hr>'s too. Changed them to <hr />.
Will I get pages not displaying correctly if my <img src=""> tags are not <img src="" alt="" /> ???
Adrian Schneider
05-25-2006, 03:59 AM
Very unlikely, but you should change them...
If you go to find/replace in templates, I think that was one of the regex examples (change img tag). This might save you some work. ;)
hambil
05-25-2006, 11:11 AM
< start tag
br start tag type
spacing
/> end tag, if there is no space its not valid as the tag is recognized as br/ not br
<br/> and any other tag with no space before the / passes validation just fine, and displays just fine in every browser I've ever tried. Try it on http://validator.w3.org/. The space is not needed.
tgreer
05-25-2006, 12:03 PM
Just to throw fuel on the fire: Google Adsense (the web's biggest evil) uses "document.write()", which is deprecated in XHTML. So all you folks using Adsense are causing your pages to be invalid XHTML.
firstrebel
05-25-2006, 01:34 PM
The /> is not a must, at the moment, as all things must be backward compatible. But as time goes on the standards will change so it is a good idea, and good housekeeping, to start using the /> now.
One error I have noticed on some of the major car manufacturers sites is not closing the <li> tag after each use. That is a basic requirement. At the moment it is not a problem as most browsers can deal with it, but the time will come when the page appearance will be affected.
Bob
tgreer
05-25-2006, 01:38 PM
The standard HAS changed. If you're using the XHTML Transitional docytpe, which vBulletin does, then the standard is "<br />".
hambil
05-25-2006, 03:20 PM
I still don't see the point. The space is just annoying.
tgreer
05-25-2006, 03:31 PM
The point is it's part of the standard. I'm not saying I like it either; but that's how it's done in xhtm, since it's based much more closely on XML, and XML requires that every tag be closed. If a tag has no ending tag, it must close "itself", and that's done by space-slash-closed angle bracket.
hambil
05-25-2006, 06:17 PM
I understand. I have no issue with the slash-closed angle bracket. It's the pointless space before it I'm not happy with.
It's like those people who code with all those extra spaces that aren't necessary and just annoy me. e.g.
if ( $a == $b ) {
my_function ( a, b );
}
Ewwwww!
Zachery
05-25-2006, 06:21 PM
I understand. I have no issue with the slash-closed angle bracket. It's the pointless space before it I'm not happy with.
It's like those people who code with all those extra spaces that aren't necessary and just annoy me. e.g.
if ( $a == $b ) {
my_function ( a, b );
}
Ewwwww!
Its there for clean presentation and validation markup, there should be a space between any attributes and next attribute.
hambil
05-25-2006, 08:31 PM
If you say so.
Zachery
05-25-2006, 09:15 PM
I do.
<img src=""/> will confuses most parsers as src=""/ would be treated as one element of the tag.
hambil
05-25-2006, 09:53 PM
That's a pretty dumb parser then, no offense.
Zachery
05-25-2006, 10:17 PM
Take it up with the W3
Adrian Schneider
05-25-2006, 10:18 PM
From http://www.w3schools.com/xhtml/xhtml_html.asp
IMPORTANT Compatibility Note:
To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol like this: <br />, and this: <hr />.
That's where I read that. A reliable source, so I'll stick to it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.