|
Posted by Steve Pugh on 03/03/07 18:16
Mike Barnard <m.barnard.trousers@thunderin.co.uk> wrote:
>I have been examining the code of a site and often, not always, there
>is a slash before the end of a statement.
>
><br class="clear" />
>
><img src="images/icon_burdick.gif" width="81" height="30"
>alt="Burdick" />
>
><br /><br />
>
><img src="images/title_latestnews.gif" width="253" height="55"
>alt="Latest News" />
>
>Why is it needed, if it is needed, and what is it good for? I
>understand </p> </h1> etc but why a /> alone?
>
>I'm sure it'll be obvious when its pointed out to me! Thanks.
It's required in XHTML. Why? Because one of the restrictions of XML
over SGML and hence of XHTML over HTML is that all elements must be
expclitl closed. Which means both that all those optional closing tags
like </p> and </li> become mandatory, and that empty elements must
close themselves and the XML syntax for that is <br />.
In practical terms it just boils downs to:
If you use XHTML use <br />, <img />, etc.
If you use HTML use <br>, <img>, etc.
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
Navigation:
[Reply to this message]
|