Forum Moderators: open

Message Too Old, No Replies

html / xhtml issues

closing slash

         

seashell

3:11 pm on Nov 19, 2003 (gmt 0)

10+ Year Member



This is a very minor question. Some of my pages are in HTML 4.01 and some XHTML 1.0. I've gotten in the habit of closing all tags, <br /> etc. Is this going to be a problem in the HTML 4.01 docs? W3C's validator doesn't seem to mind, but others do.

choster

3:50 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's more of a problem in some tags than in others. For instance, there's been discussion here in the past about <meta />-- some spiders interpret this as closing the entire <head>-- and so various members had taken to using <meta></meta>.

As long as you provide a space in front of the closing slash, most older browsers will muddle by; in fact, the space in front of the closing slash is recommended specifically for backwards-compatibility. <br />, <img />, and <hr /> all render fine for us on Netscape 3. Of course, what renders isn't the same as what's valid, but then W3C's validation engine may deserve more weight than third party software or plugins.

encyclo

3:51 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<br /> is valid HTML 4, but it doesn't mean the same thing as you think it does. In theory, it is the equivalent of:

<br>&gt;

Luckily, no browsers (AFAIK) render it in this way. However, you are dependent on the browser's error-handling. It has to be said, when you're sending XHTML with a

text/html
mime type, the same situation applies.

In the real world, you are very unlikely to encounter any problems, but if you want your HTML4 to be "correct" (not just pass the validation), you should use

<br>
.