| Chris Devers 2004-09-12, 8:55 pm |
| On Thu, 9 Sep 2004, Robert Page IV wrote:
> I am familiar with <br>. What is the difference between <br> and <br />?
It's an XHTML / XML -ism.
In strict XML markup -- of which XHTML is one example -- all tags have
to be balanced. For HTML, this means that tags that it used to be okay
to leave unbalanced -- <p> paragraphs with no closing </p>, etc -- all
now need to have that closing tag.
For singleton tags like <br>, <hr> and <img>, the rule still applies, so
that in theory you're supposed to be write <br></br>, <img ...></img>,
etc.
Because this is really annoying, XML allows a special case where tags
that do not contain any content -- that is, <br></br> -- can simply be
abbreviated to <br />, and the "/>" implies the closing tag.
If you're still writing pre-XHTML web page markup, it doesn't really
matter, but it's a good habit to develop, as eventually HTML as it has
been sloppily used for a decade now is going to be phased out. (Well ok
probably not phased out, but new tools will eventually stop supporting
it, so you'll have to use old browswers (etc) to view old documents.)
--
Chris Devers
|