Typing Markup Tags Ending in />

N

Nathan Sokalski

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

Nathan Sokalski

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?
 
M

Martin Milan

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
 
J

Jay B. Harlow

Do you *really* want your code to be non XHTML-compliant and non
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.
 
C

Cor Ligthert [MVP]

[ 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
 
P

Phil H

Nathan said:
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.

If you select the menu "Tool" | "Options" and then select "Text Editor"
- "HTML" - "Format" (in the left hand pane) and then click the "Tag
specific Options" button, you will then see "Default Settings" -
"Client does not support contents", which will allow you to choose how
such tags are handled.

However there doesn't appear to be any option for removing the space. I
am inclined to take that as hard coded in VS2005

The form <br /> is not a requirement for XHTML but the space is
recommended for backward compatability with HTML:

http://www.w3.org/TR/2002/REC-xhtml1-20020801/#xhtml

See paragraph C.2. Empty elements
 
A

_AnonCoward

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

Nathan Sokalski

There are options on how to handle the set of tags that includes <br />
there, but I could not find anywhere that lets you specify whether or not to
include the space. The only option I could find that actually changed the
tag itself was the Closing Tag option, which is basically choosing between
<br /> and <br>, and given that choice I definitely would choose <br />. Did
I miss the section you were talking about? Thanks.
 

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

Top