Forum Moderators: open

Message Too Old, No Replies

<br> vs. <br />

I've seen both ways

         

seashell

2:28 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



I've seen <br> and <br />. Is there a reason for the / at the end?

dmorison

2:33 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<br/> (or preferably <br />) is for use in XHTML, in which all tags have to be closed, even those that do not normally have a closing tag. /> is the shorthand for closing a tag without repeating the entire tag name; so instead of using <br></br> you just use <br />.

seashell

2:35 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



Awesome, that's kind of what I suspected.

ukgimp

2:37 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I found out this weekend that the space is due to browser weirdness, forget which one but one of them throws an error. So best to use it.

Cheers

jetboy_70

2:43 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



"I found out this weekend that the space is due to browser weirdness, forget which one"

That's because you could barely stand ;) Netscape 4.

DaveN

2:48 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ukgimp I think it was to do with Mac's could be wrong.

DaveN

g1smd

8:22 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Leave the / out if you are writing HTML code. You get some very wierd validation errors if you put an ending / in the code in HTML.

You must put it in, only in XHTML.

korkus2000

11:32 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another common one is the image tag:

<img src="gif.gif" />

D_Blackwell

6:24 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I validate 4.01 Strict with <br /> and <img /> but <hr /> won't validate. I have to stick with <hr>. Can anyone tell me why? Is <hr> an orange in an apple barrel?

jetboy_70

11:15 am on Sep 24, 2003 (gmt 0)

10+ Year Member



<hr /> / <hr/> is certainly a valid XHTML tag. Possibly a bug in the validator, or more likely something close to the tag in your code causing it to misreport. Can you post a section of code and the validator output?

g1smd

12:12 am on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



While it is valid XHTML, he said that he is using HTML 4 Strict.

I would remove all of the "XHTML-style" code if you are using HTML 4.

jetboy_70

1:17 am on Sep 25, 2003 (gmt 0)

10+ Year Member



Which you mentioned earlier as well. Too much typing and not enough reading on my part - well spotted. Of course D_Blackwell could always validate to XHTML 1.0 Transitional instead, which would be a step forward, standards-wise.

D_Blackwell

2:09 am on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It hasn't been all that long that I've been validating at all! Started with 4.0 loose or transitional and had scads of errors. (Although mostly similar errors repeated many many times.)

Dipped my toe into strict one day to see what would happen. I found that it wasn't that big a jump at all and switched almost immediately.

I really know very little about xhtml. How big a jump would this be? What are the most obvious considerations to watch out for? Validation has raised the standard of my work immensely and made further progress much easier.

Downside? Tansitional to start? Or whole hog to strict?

jetboy_70

9:03 am on Sep 25, 2003 (gmt 0)

10+ Year Member



Stick with transitional if you're after some degree of compatibility with older browers like Netscape 4. I'd start with reading the W3C spec at [w3.org...] and then validating your document to XHTML 1.0 Transitional. Fix the errors ... there's your XHTML! It may be a little simplistic but that's how I started, and if you're already producing valid HTML you won't have that much to change.

The code you produce might validate, but to code in the 'spirit' of XHTML you should be taking full advantage of CSS. That's for another post though ...

keyplyr

9:05 am on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This thread HTML vs. XHTML [webmasterworld.com] covers it nicely.

D_Blackwell

2:48 pm on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks keyplyr,

An interesting thread. For now, I think I'll be content with things as they are. Except for those 'tag every line' references, I'm already doing almost everything that I saw mentioned anyway. It seems that the code I am using will be solid for a long time. I don't want to get ridiculous with standards and compliance. There's too much else to do.