Ending tags with />

T

Tim Johansson

Is it standard to end tags like <img>> with a />?

I'm only wondering if it's worth trying to get used to writing this way.
 
D

Dylan Parry

Tim said:
Is it standard to end tags like <img>> with a />?

I'm only wondering if it's worth trying to get used to writing this way.

Elements that are written like <element /> are part of XHTML. They are
written like this if they are empty elements, ie. do not have a closing
tag in HTML and do not contain any textual content.

If you are writing regular HTML, then you don't need to do this. Only if
you were using XHTML (which you obviously aren't) do you have to do it
that way.

HTH
 
N

Neal

Elements that are written like <element /> are part of XHTML. They are
written like this if they are empty elements, ie. do not have a closing
tag in HTML and do not contain any textual content.

If you are writing regular HTML, then you don't need to do this. Only if
you were using XHTML (which you obviously aren't) do you have to do it
that way.

HTH

I'll add that in HTMl you don't want to do it. Using the slash in, say, a
link element can lead to problems with HTML.
 
D

David Dorward

Dylan said:
Elements that are written like <element /> are part of XHTML...
If you are writing regular HTML, then you don't need to do this.

It isn't optional. If you are writing regular HTML then you should not do
this at all. The closing slash means something somewhat different in HTML.
 
E

Eric B. Bednarz

David Dorward said:
It isn't optional. If you are writing regular HTML then you should not do
this at all. The closing slash means something somewhat different in HTML.

Actually it is the '>' character that means something completely
different in XHTML in this context. The 'closing' slash and the
'greater than' character have *nothing* to do with the EndTAGOpen
delimiter '</' and the TagClose delimiter '>' respectively.

In HTML, there is only one NullEndTag delimiter (the solidus) that would
appear as a matching pair if the content model of the element type is
*not* empty:

<foo/some foo text/

or simply

<foo//

if there were no content at all.

XML, however, uses the possibility introduced by Annex K of ISO8879 to
specify a *different character* as a *start* delimiter of the NET
shorthand feature, id est NetEnablingStartTagClose.

And in XML, they sadistically mapped the good old NET to '>' and NESTC
to the good old solidus ("it's a tag, Joe").

So, the ugly, asymmetrical, sexually frustrated <foo// larva can
transform into the beautiful <foo/> butterfly (if the element instance
does either not have any content or the element type's content model is
EMPTY) and live happily ever after.

It's a damned miracle (especially if you read all the helpful
explanations at jolly good low-contrast microfont e-zines about stuff
like this).
 
D

Dylan Parry

David said:
It isn't optional. If you are writing regular HTML then you should not do
this at all. The closing slash means something somewhat different in HTML.

I guess the late night Usenetting clouded my language. What I meant by the
above is that you shouldn't do it, ie. you don't need to do it because it
is invalid in HTML. That'll teach me to go to bed earlier :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top