What is "/>"?

Discussion in 'HTML' started by michaaal, Jul 20, 2004.

  1. michaaal

    michaaal Guest

    I have been programming in HTML for 3 years and I usually program in this
    format...

    <input type="text">

    ...I have seen people use this type of format...

    <input type="text />

    What is the extra slash for? Am I missing something?
     
    michaaal, Jul 20, 2004
    #1
    1. Advertising

  2. "michaaal" <> wrote in news:FV8Lc.19716$gt1.1104
    @nwrddc02.gnilink.net:

    > I have been programming in HTML for 3 years and I usually program in this
    > format...
    >
    > <input type="text">
    >
    > ..I have seen people use this type of format...
    >
    > <input type="text />
    >
    > What is the extra slash for? Am I missing something?


    Some HTML tags are not pairs or you have a choice of writing them as a pair
    or not.

    <tag></tag> or <tag />

    for example.

    <img src="/images/image.php" alt="image of me" />

    <hr />


    --
    Edward Alfert
    http://www.rootmode.com/
    Multiple Domain Hosting and Reseller Hosting Plans
    Coupon Code (Recurring $5/month Discount): newsgroup
     
    Edward Alfert, Jul 20, 2004
    #2
    1. Advertising

  3. michaaal

    Rob Collyer Guest

    "michaaal" <> wrote in news:FV8Lc.19716$gt1.1104
    @nwrddc02.gnilink.net:

    > I have been programming in HTML for 3 years and I usually program in

    this
    > format...
    >
    > <input type="text">
    >
    > ..I have seen people use this type of format...
    >
    > <input type="text />
    >
    > What is the extra slash for? Am I missing something?
    >
    >
    >


    The extra slash is required by XHTML for elements that do not have a
    closing element....

    For instance
    <img src="blah" />
    <br />
    <input type="text" />


    valid XHTML requires all elements to be closed.... the extra slash tells
    the browser to close the element there and then.... it is both the
    opening, and closing element in one.

    Hope this helps.

    --
    Robert Collyer
    www.webforumz.com
    Free Web Design and Development Help, Discussions, tips and Critique!
    ASP, VB, .NET, SQL, CSS, HTML, Javascript, Flash, XML, SEO !
     
    Rob Collyer, Jul 20, 2004
    #3
  4. michaaal

    Neil Monk Guest

    Rob Collyer wrote:
    > "michaaal" <> wrote in news:FV8Lc.19716$gt1.1104
    > @nwrddc02.gnilink.net:
    >
    >> I have been programming in HTML for 3 years and I usually program in
    >> this format...
    >>
    >> <input type="text">
    >>
    >> ..I have seen people use this type of format...
    >>
    >> <input type="text />
    >>
    >> What is the extra slash for? Am I missing something?
    >>
    >>
    >>

    >
    > The extra slash is required by XHTML for elements that do not have a
    > closing element....
    >
    > For instance
    > <img src="blah" />
    > <br />
    > <input type="text" />
    >
    >
    > valid XHTML requires all elements to be closed.... the extra slash
    > tells the browser to close the element there and then.... it is both
    > the opening, and closing element in one.
    >
    > Hope this helps.

    It certianly did, good clear explanation Rob.

    Thanks.
    --
    Neil
    ** http://www.neilmonk.com
    ** (change the colour to blue)
     
    Neil Monk, Jul 20, 2004
    #4
  5. michaaal

    Andy Dingley Guest

    "Neil Monk" <neil.monk02@__REMOVE__NO__SPAM__blueyonder.co.uk> wrote in message news:<mB9Lc.3953$>...
    > Rob Collyer wrote:


    > > Hope this helps.

    > It certianly did, good clear explanation Rob.


    Don't worry, at least twenty people will post soon to correct (sic)
    and nit-pick.
    :cool:


    If you care about this stuff, read the XML spec and Appendix C of the
    XHTML 1.0 spec.

    If you don't care about this stuff, then just use the " />" form to
    make sure that every element is closed somehow. BUT always write
    empty elements as "<br />" (with a space in them), or some readers
    see them as a tag name "br/" (which is wrong). Also make sure that
    you don't use the XML short form for HTML elements that aren't empty
    elements. Stick with <script ... ></script>, or IE6 will make your
    whole page disappear!
     
    Andy Dingley, Jul 20, 2004
    #5
  6. michaaal

    Kurt Weber Guest

    "michaaal" <> wrote in message
    news:FV8Lc.19716$...
    > I have been programming in HTML for 3 years


    No, you haven't.

    > and I usually program in this
    > format...


    I doubt it.

    > ..I have seen people use this type of format...
    >
    > <input type="text />
    >
    > What is the extra slash for? Am I missing something?
    >


    It's required by XHTML--all elements are required to be closed, so the
    slash at the end tells the client to close the element right then and there.

    --
    Kurt Weber
     
    Kurt Weber, Jul 20, 2004
    #6
  7. michaaal

    Sam Hughes Guest

    On 20 Jul 2004 13:20:07 GMT, Edward Alfert <> wrote:

    > "michaaal" <> wrote in news:FV8Lc.19716$gt1.1104
    > @nwrddc02.gnilink.net:
    >
    >> I have been programming in HTML for 3 years and I usually program in
    >> this
    >> format...
    >>
    >> <input type="text">
    >>
    >> ..I have seen people use this type of format...
    >>
    >> <input type="text />
    >>
    >> What is the extra slash for? Am I missing something?

    >
    > Some HTML tags are not pairs or you have a choice of writing them as a
    > pair
    > or not.
    >
    > <tag></tag> or <tag />
    >
    > for example.
    >
    > <img src="/images/image.php" alt="image of me" />
    >
    > <hr />


    Not exactly. The above is only true for XHTML. If you're writing to an
    HTML spec, that form of code should not be used.
     
    Sam Hughes, Jul 20, 2004
    #7
  8. michaaal

    Toby Inkster Guest

    Kurt Weber wrote:

    > It's required by XHTML--all elements are required to be closed, so the
    > slash at the end tells the client to close the element right then and there.


    Not really *required*. You can happily write XHTML without a single "/>".

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Jul 21, 2004
    #8
  9. "michaaal" <> wrote in message
    news:FV8Lc.19716$...
    > I have been programming in HTML for 3 years and I usually program in this
    > format...
    >
    > <input type="text">
    >
    > ..I have seen people use this type of format...
    >
    > <input type="text />
    >
    > What is the extra slash for? Am I missing something?
    >
    >


    /> Is the empty-element and forms a self closing tag

    / > ( Slash space angle-bracket ) is used for compatibility so non XHTML
    browswers can render xhtml documents

    from the xhtml spec:


    C.2. Empty Elements
    Include a space before the trailing / and > of empty elements, e.g. <br />,
    <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag
    syntax for empty elements, e.g. <br />, as the alternative syntax <br></br>
    allowed by XML gives uncertain results in many existing user agents.
     
    Spacen Jasset, Jul 21, 2004
    #9
  10. michaaal

    Els Guest

    Spacen Jasset wrote:

    > "michaaal" <> wrote in message
    > news:FV8Lc.19716$...
    >> I have been programming in HTML for 3 years and I usually
    >> program in this format...
    >>
    >> <input type="text">
    >>
    >> ..I have seen people use this type of format...
    >>
    >> <input type="text />
    >>
    >> What is the extra slash for? Am I missing something?
    >>
    >>

    >
    > /> Is the empty-element and forms a self closing tag
    >
    > / > ( Slash space angle-bracket )


    You mean /> (space slash angle-bracket), as you state
    yourself below :)

    > is used for compatibility
    > so non XHTML browswers can render xhtml documents
    >
    > from the xhtml spec:
    >
    > C.2. Empty Elements
    > Include a space before the trailing / and > of empty
    > elements, e.g. <br />, <hr /> and <img src="karen.jpg"
    > alt="Karen" />. Also, use the minimized tag syntax for
    > empty elements, e.g. <br />, as the alternative syntax
    > <br></br> allowed by XML gives uncertain results in many
    > existing user agents.


    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Now playing: Nick Lowe - Sound Of Breaking Glass
     
    Els, Jul 21, 2004
    #10
  11. "Sam Hughes" <> wrote in news:eek:psbgj0vgesoqfra@vze2r9w:

    > On 20 Jul 2004 13:20:07 GMT, Edward Alfert <>
    > wrote:
    >
    >> "michaaal" <> wrote in news:FV8Lc.19716$gt1.1104
    >> @nwrddc02.gnilink.net:
    >>
    >>> I have been programming in HTML for 3 years and I usually program in
    >>> this
    >>> format...
    >>>
    >>> <input type="text">
    >>>
    >>> ..I have seen people use this type of format...
    >>>
    >>> <input type="text />
    >>>
    >>> What is the extra slash for? Am I missing something?

    >>
    >> Some HTML tags are not pairs or you have a choice of writing them as
    >> a pair
    >> or not.
    >>
    >> <tag></tag> or <tag />
    >>
    >> for example.
    >>
    >> <img src="/images/image.php" alt="image of me" />
    >>
    >> <hr />

    >
    > Not exactly. The above is only true for XHTML. If you're writing to
    > an HTML spec, that form of code should not be used.



    Thanks...time for me to brush up on my coding.


    --
    Edward Alfert
    http://www.rootmode.com/
    Multiple Domain Hosting and Reseller Hosting Plans
    Coupon Code (Recurring $5/month Discount): newsgroup
     
    Edward Alfert, Jul 21, 2004
    #11
  12. "Els" <> wrote in message
    news:Xns952D16E324E9EEls@130.133.1.4...
    > Spacen Jasset wrote:


    ....

    > You mean /> (space slash angle-bracket), as you state
    > yourself below :)


    ....

    Some days I don't know what I mean. Yes, that's right space slash angle
     
    Spacen Jasset, Jul 21, 2004
    #12
  13. michaaal

    michaaal Guest

    Thanks so much to those of you who answered my question!
     
    michaaal, Jul 22, 2004
    #13
    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.

Share This Page