Typing Markup Tags Ending in />

Discussion in 'ASP .Net' started by Nathan Sokalski, Dec 30, 2006.

  1. I often use self-closing tags (such as <br/>) when creating an ASP.NET
    application. However, when I enter them in Visual Studio .NET 2005, it
    automatically inserts a space before the />. In most cases this does not
    bother me, but for tags such as <br/> that I usually do not use any
    attributes with I prefer not to have the extra space. I there a way to
    prevent Visual Studio .NET 2005 from inserting the extra space before the />
    at the end of the tag? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Dec 30, 2006
    #1
    1. Advertising

  2. Nathan Sokalski

    Mark Rae Guest

    "Nathan Sokalski" <> wrote in message
    news:...

    > I there a way to prevent Visual Studio .NET 2005 from inserting the extra
    > space before the /> at the end of the tag?


    Do you *really* want your code to be non XHTML-compliant and non
    cross-browser compatible...?
    http://www.w3schools.com/xhtml/xhtml_howto.asp
     
    Mark Rae, Dec 30, 2006
    #2
    1. Advertising

  3. Is <br/> really non XHTML-compliant? Visual Studio .NET might try to create
    <br /> instead, but it doesn't mark my tags with a warning or anything. I
    didn't think getting rid of the space before the / was breaking the rules of
    XHTML. Is it?
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Mark Rae" <> wrote in message
    news:%23dKpND%...
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >
    >> I there a way to prevent Visual Studio .NET 2005 from inserting the extra
    >> space before the /> at the end of the tag?

    >
    > Do you *really* want your code to be non XHTML-compliant and non
    > cross-browser compatible...?
    > http://www.w3schools.com/xhtml/xhtml_howto.asp
    >
     
    Nathan Sokalski, Dec 30, 2006
    #3
  4. Nathan Sokalski

    Mark Rae Guest

    "Nathan Sokalski" <> wrote in message
    news:uvnvhg%...

    > Is <br/> really non XHTML-compliant? Visual Studio .NET might try to
    > create <br /> instead, but it doesn't mark my tags with a warning or
    > anything. I didn't think getting rid of the space before the / was
    > breaking the rules of XHTML. Is it?


    It is, in the sense that the XHTML specification quite clearly specifies <br
    />, not <br/>

    Some browsers e.g. Netscape don't understand <br/>

    Your call...
     
    Mark Rae, Dec 30, 2006
    #4
  5. [ Excessive newsgroup list trimmed in this reply. ]

    Nathan,

    > I didn't think getting rid of the space before the / was breaking the
    > rules of XHTML. Is it?


    No need to worry, it is OK to both include or leave out the space before the
    "/>" characters.

    From the XML 1.1 specification (XHTML is based on XML) published by W3C:

    http://www.w3.org/TR/xml11/#sec-starttags

    ....you may find definition #44, which defines an empty tag like <BR> as
    follows:

    EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'

    Here, "Name" is the name of the tag, i.e. "BR", and "S" stands for a white
    space, like a space or tab (one or more). At the end, there's "S?" and
    followed with the "/>" characters. The question mark after the "S" is an
    occurrence indicator, and means that the white space can exist, or not exist
    at all.

    So, both "<BR/>" and "<BR />" are correct as far as the specification goes,
    but the latter might be a bit easier to read (subjective) whereas the former
    takes little less space.

    Happy New Year!

    --
    Regards,

    Mr. Jani Järvinen
    C# MVP
    Helsinki, Finland

    http://www.saunalahti.fi/janij/
     
    Jani Järvinen [MVP], Dec 30, 2006
    #5
  6. Nathan Sokalski

    Martin Milan Guest

    "Nathan Sokalski" <> wrote in
    news::

    > I often use self-closing tags (such as <br/>) when creating an ASP.NET
    > application. However, when I enter them in Visual Studio .NET 2005, it
    > automatically inserts a space before the />. In most cases this does
    > not bother me, but for tags such as <br/> that I usually do not use
    > any attributes with I prefer not to have the extra space. I there a
    > way to prevent Visual Studio .NET 2005 from inserting the extra space
    > before the /> at the end of the tag? Thanks.


    You wouldn't want to do this. It is merely following the XHTML
    standards.

    Martin
     
    Martin Milan, Dec 30, 2006
    #6
  7. "Nathan Sokalski" <> schrieb:
    > Is <br/> really non XHTML-compliant?


    No, it is valid XHTML.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Herfried K. Wagner [MVP], Dec 30, 2006
    #7
  8. Nathan Sokalski

    Mark Rae Guest

    "Mark Rae" <> wrote in message
    news:%23EplZt%...

    > "Nathan Sokalski" <> wrote in message
    > news:uvnvhg%...
    >
    >> Is <br/> really non XHTML-compliant? Visual Studio .NET might try to
    >> create <br /> instead, but it doesn't mark my tags with a warning or
    >> anything. I didn't think getting rid of the space before the / was
    >> breaking the rules of XHTML. Is it?

    >
    > It is, in the sense that the XHTML specification quite clearly specifies
    > <br />, not <br/>
    >
    > Some browsers e.g. Netscape don't understand <br/>
    >
    > Your call...


    Just to be *absolutely* clear on this:
    http://www.w3.org/TR/xhtml1/#prohibitions

    Read paragraph C.2
     
    Mark Rae, Dec 30, 2006
    #8
  9. > You wouldn't want to do this. It is merely following the XHTML
    > standards.

    Umm...

    According to the W3C Markup Validation Service http://validator.w3.org/ both
    <br/> and <br /> compliant XHTML 1.1!

    Remember the w3.org is the group that defines the standard.

    --
    Hope this helps
    Jay B. Harlow
    ..NET Application Architect, Enthusiast, & Evangelist
    T.S. Bradley - http://www.tsbradley.net


    "Martin Milan" <> wrote in message
    news:Xns98A96F516743DI8spmido@194.117.143.37...
    > "Nathan Sokalski" <> wrote in
    > news::
    >
    >> I often use self-closing tags (such as <br/>) when creating an ASP.NET
    >> application. However, when I enter them in Visual Studio .NET 2005, it
    >> automatically inserts a space before the />. In most cases this does
    >> not bother me, but for tags such as <br/> that I usually do not use
    >> any attributes with I prefer not to have the extra space. I there a
    >> way to prevent Visual Studio .NET 2005 from inserting the extra space
    >> before the /> at the end of the tag? Thanks.

    >
    > You wouldn't want to do this. It is merely following the XHTML
    > standards.
    >
    > Martin
     
    Jay B. Harlow, Dec 30, 2006
    #9
  10. > Do you *really* want your code to be non XHTML-compliant and non
    > cross-browser compatible...?
    > http://www.w3schools.com/xhtml/xhtml_howto.asp

    Unfortunately w3shcools.com is *not* the authority on internet standards.

    Remember that http://www.w3.org is the group that defines the standard. I
    would rely on w3.org for the authority on internet standards. Then rely on
    other groups, such as w3shcools.com, for quirks (pun intended) that specific
    browsers exhibit.

    According to the W3C Markup Validation Service http://validator.w3.org/ both
    <br/> and <br /> are compliant XHTML 1.1!

    In fact the XHTML 1.0 Recommendation uses <br/> (no space) in their
    examples! (heading 4.6 Empty Elements)

    http://www.w3.org/TR/xhtml1/

    Further depending on how old the howto page is, it may be totally
    immaterial! What percentage of users, of the OP's web site, actually use
    Netscape. What percentage of their users, use a version of Netscape that
    exhibits the problem.

    --
    Hope this helps
    Jay B. Harlow
    ..NET Application Architect, Enthusiast, & Evangelist
    T.S. Bradley - http://www.tsbradley.net


    "Mark Rae" <> wrote in message
    news:%23dKpND%...
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >
    >> I there a way to prevent Visual Studio .NET 2005 from inserting the extra
    >> space before the /> at the end of the tag?

    >
    > Do you *really* want your code to be non XHTML-compliant and non
    > cross-browser compatible...?
    > http://www.w3schools.com/xhtml/xhtml_howto.asp
    >
     
    Jay B. Harlow, Dec 30, 2006
    #10
  11. Nathan,
    As Herfried suggests <br/> is valid XHTML.

    I normally use the W3C Markup Validation Service http://validator.w3.org/ to
    verify compliant XHTML.

    --
    Hope this helps
    Jay B. Harlow
    ..NET Application Architect, Enthusiast, & Evangelist
    T.S. Bradley - http://www.tsbradley.net


    "Nathan Sokalski" <> wrote in message
    news:uvnvhg%...
    > Is <br/> really non XHTML-compliant? Visual Studio .NET might try to
    > create <br /> instead, but it doesn't mark my tags with a warning or
    > anything. I didn't think getting rid of the space before the / was
    > breaking the rules of XHTML. Is it?
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Mark Rae" <> wrote in message
    > news:%23dKpND%...
    >> "Nathan Sokalski" <> wrote in message
    >> news:...
    >>
    >>> I there a way to prevent Visual Studio .NET 2005 from inserting the
    >>> extra space before the /> at the end of the tag?

    >>
    >> Do you *really* want your code to be non XHTML-compliant and non
    >> cross-browser compatible...?
    >> http://www.w3schools.com/xhtml/xhtml_howto.asp
    >>

    >
    >
     
    Jay B. Harlow, Dec 30, 2006
    #11
  12. Jay,

    "Jay B. Harlow" <> schrieb:
    > I normally use the W3C Markup Validation Service http://validator.w3.org/
    > to verify compliant XHTML.


    I prefer Christoph Schneegans' validator because it provides more accurate
    results (it validates against XML schemas):

    XML Schema Validator
    <URL:http://schneegans.de/sv/>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Herfried K. Wagner [MVP], Dec 30, 2006
    #12
  13. [ Excessive newsgroup list trimmed in this reply. ]

    Nathan,

    It is one of the last things I would make a point from so I am not sure if
    it is in it.
    (That does not mean that you should do the same as me).

    If you are working in Source View and you have the workbar HTML selected
    than there is a dropdownbox where you can select what kind of HTML code you
    want use, maybe it is between one of those those.

    Cor



    "Nathan Sokalski" <> schreef in bericht
    news:...
    >I often use self-closing tags (such as <br/>) when creating an ASP.NET
    >application. However, when I enter them in Visual Studio .NET 2005, it
    >automatically inserts a space before the />. In most cases this does not
    >bother me, but for tags such as <br/> that I usually do not use any
    >attributes with I prefer not to have the extra space. I there a way to
    >prevent Visual Studio .NET 2005 from inserting the extra space before the
    >/> at the end of the tag? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
     
    Cor Ligthert [MVP], Dec 30, 2006
    #13
  14. Thanks for the link, I've saved a copy for future reference.

    --
    Hope this helps
    Jay B. Harlow
    ..NET Application Architect, Enthusiast, & Evangelist
    T.S. Bradley - http://www.tsbradley.net


    "Herfried K. Wagner [MVP]" <> wrote in message
    news:...
    > Jay,
    >
    > "Jay B. Harlow" <> schrieb:
    >> I normally use the W3C Markup Validation Service http://validator.w3.org/
    >> to verify compliant XHTML.

    >
    > I prefer Christoph Schneegans' validator because it provides more accurate
    > results (it validates against XML schemas):
    >
    > XML Schema Validator
    > <URL:http://schneegans.de/sv/>
    >
    > --
    > M S Herfried K. Wagner
    > M V P <URL:http://dotnet.mvps.org/>
    > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Jay B. Harlow, Dec 30, 2006
    #14
  15. Nathan Sokalski

    _AnonCoward Guest

    "Nathan Sokalski" <> wrote in message
    news:...
    :
    : I often use self-closing tags (such as <br/>) when creating an
    : ASP.NET application. However, when I enter them in Visual Studio
    : .NET 2005, it automatically inserts a space before the />. In
    : most cases this does not bother me, but for tags such as <br/>
    : that I usually do not use any attributes with I prefer not to
    : have the extra space. I there a way to prevent Visual Studio
    : .NET 2005 from inserting the extra space before the /> at the
    : end of the tag? Thanks.

    I believe this goes back to some older browsers (earlier netscape
    browsers, if memory serves) that would not render <br/> or <hr/>
    correctly without the interveneing space character.

    Ralf
    --
    --
    ----------------------------------------------------------
    * ^~^ ^~^ *
    * _ {~ ~} {~ ~} _ *
    * /_``>*< >*<''_\ *
    * (\--_)++) (++(_--/) *
    ----------------------------------------------------------
    There are no advanced students in Aikido - there are only
    competent beginners. There are no advanced techniques -
    only the correct application of basic principles.
     
    _AnonCoward, Jan 2, 2007
    #15
    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. Victoria
    Replies:
    1
    Views:
    528
    Collin VanDyck
    Mar 1, 2004
  2. Tim Johansson

    Ending tags with />

    Tim Johansson, Aug 7, 2004, in forum: HTML
    Replies:
    5
    Views:
    502
    Dylan Parry
    Aug 7, 2004
  3. JimLad
    Replies:
    0
    Views:
    499
    JimLad
    Jan 26, 2010
  4. Nathan Sokalski

    Typing Markup Tags Ending in />

    Nathan Sokalski, Dec 30, 2006, in forum: ASP .Net Web Controls
    Replies:
    8
    Views:
    143
    Jay B. Harlow
    Dec 30, 2006
  5. Andreas Semt
    Replies:
    4
    Views:
    329
    Andreas Semt
    Jan 18, 2005
Loading...

Share This Page