Forum Moderators: phranque

Message Too Old, No Replies

/>

why?

         

DashTwo

12:03 pm on Mar 5, 2006 (gmt 0)

10+ Year Member



I don't believe there is a difference between
/>
and
>
when closing a tag. But why two in the first place? And is one of them a standard?

mecjfl

12:05 pm on Mar 5, 2006 (gmt 0)



the first on is xhtml ignore it it sux

dmorison

2:00 pm on Mar 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For an XML document to be well formed (which an XHTML document should be); all tags must be closed. Within XML, there are 2 ways to close tags. The normal way:

<tag>data</tag>

and the shortand method, which can only be used when there is no data:

<tag />

Now, because there are a number of HTML elements that never have data (such as <br>, <hr> for example), it is common practice within XHTML to close off these tags using the shorthand method, and hense they become <br /> and <hr />. If this shorthand method were not an option then for an XHTML document to be valid XML it would be necessary to close the tags, and that would mean using <br></br>....

Vishal

10:24 pm on Mar 5, 2006 (gmt 0)

10+ Year Member



Helllo dmorison,

Thank you for good definition. It makes more sense to me now.

longen

11:33 pm on Mar 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Likewise the <img> tag:

<img src="" width="" height="" alt="" />

netchicken1

11:38 pm on Mar 5, 2006 (gmt 0)

10+ Year Member



Good question and great answers!
It always bugged me as well...

Wlauzon

12:05 am on Mar 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the first on is xhtml ignore it it sux

Not exactly the most informative post in the pile, is it?

4serendipity

2:51 am on Mar 6, 2006 (gmt 0)

10+ Year Member



the first on is xhtml ignore it it sux

Not exactly the most informative post in the pile, is it?

And not the most clear post either. I actually had to read it a couple times to get the gist of it :)

In all seriousness, I've found webmasterworld to consistently have a high signal to noise ratio, so I don't get too upset with the occasional junk post.

Back to XHTML and whether or not it "sux", you can do some web searches and find Ian Hickson's piece "Sending XHTML as text/html Considered Harmful" and responses to Ian's article to get a good idea about the differences between HTML and XHTML and advantages/disadvantages of both.