Ending tags with />

Discussion in 'HTML' started by Tim Johansson, Aug 7, 2004.

  1. 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.

    --
    --
    www.gurka.se/gurka.php?x=1&language=english
    Tremble before the mighty Cucumber
     
    Tim Johansson, Aug 7, 2004
    #1
    1. Advertising

  2. Tim Johansson

    Dylan Parry Guest

    Tim Johansson wrote:

    > 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

    --
    Dylan Parry
    http://webpageworkshop.co.uk - FREE Web tutorials and references

    'I am a Bear of Very Little Brain, and long words bother me.' -- A A Milne
     
    Dylan Parry, Aug 7, 2004
    #2
    1. Advertising

  3. Tim Johansson

    Neal Guest

    On Sat, 07 Aug 2004 01:58:53 +0100, Dylan Parry <>
    wrote:

    > Tim Johansson wrote:
    >
    >> Is it standard to end tags like &lt;img&gt;> with a /&gt;?
    >>
    >> 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
    >


    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.
     
    Neal, Aug 7, 2004
    #3
  4. Dylan Parry wrote:

    > 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.


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Aug 7, 2004
    #4
  5. David Dorward <> writes:

    > Dylan Parry wrote:
    >
    >> 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.


    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).


    --
    | )
    -( 111010111011
    | )
     
    Eric B. Bednarz, Aug 7, 2004
    #5
  6. Tim Johansson

    Dylan Parry Guest

    David Dorward wrote:

    >> 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.


    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 :)

    --
    Dylan Parry
    http://webpageworkshop.co.uk - FREE Web tutorials and references

    'I am a Bear of Very Little Brain, and long words bother me.' -- A A Milne
     
    Dylan Parry, Aug 7, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dean H. Saxe
    Replies:
    0
    Views:
    1,079
    Dean H. Saxe
    Jan 3, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    836
    Rob Nicholson
    May 28, 2005
  3. Ranganath

    Custom Tags within Custom Tags.

    Ranganath, Oct 17, 2003, in forum: Java
    Replies:
    2
    Views:
    488
    Ranganath
    Oct 21, 2003
  4. Nathan Sokalski

    Typing Markup Tags Ending in />

    Nathan Sokalski, Dec 30, 2006, in forum: ASP .Net
    Replies:
    14
    Views:
    728
    _AnonCoward
    Jan 2, 2007
  5. Nathan Sokalski

    Typing Markup Tags Ending in />

    Nathan Sokalski, Dec 30, 2006, in forum: ASP .Net Web Controls
    Replies:
    8
    Views:
    157
    Jay B. Harlow
    Dec 30, 2006
Loading...

Share This Page