在/>中键入标记标记结尾 [英] Typing Markup Tags Ending in />

查看:91
本文介绍了在/>中键入标记标记结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建ASP.NET

应用程序时,我经常使用自动关闭标记(例如< br />)。但是,当我在Visual Studio .NET 2005中输入它们时,

会自动在/>之前插入一个空格。在大多数情况下,这不会打扰我,但是对于像< br /这样的标签,我通常不使用任何

属性,我更喜欢没有额外的空间。我有办法让

阻止Visual Studio .NET 2005在标签末尾的/>

之前插入多余的空格?谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/

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
nj********@hotmail.com
http://www.nathansokalski.com/

推荐答案

" Nathan Sokalski" < nj ******** @ hotmail.comwrote in message

news:eJ ************** @ TK2MSFTNGP03.phx.gbl .. 。
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...

我有办法阻止Visual Studio .NET 2005在标签结尾处插入额外的

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



你真的*真的*希望你的代码不符合XHTML标准,而且不需要b / b
跨浏览器兼容......?
http://www.w3schools.com/xhtml/xhtml_howto.asp


< br /真的不符合XHTML标准? Visual Studio .NET可能会尝试创建

< br /,但它并没有用警告或任何东西标记我的标签。我没想到在打破/ b
XHTML的规则之前摆脱了空间。是吗?

-

Nathan Sokalski
nj ********@hotmail.com
http:/ /www.nathansokalski.com/


" Mark Rae" < ma ** @ markNOSPAMrae.com写信息

新闻:%2 ****************** @ TK2MSFTNGP02.phx.gbl ...
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
nj********@hotmail.com
http://www.nathansokalski.com/

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...

" Nathan Sokalski" < nj ******** @ hotmail.comwrote in message

news:eJ ************** @ TK2MSFTNGP03.phx.gbl .. 。
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...

>我有办法阻止Visual Studio .NET 2005在标记结尾之前插入额外的
空格吗?
>I there a way to prevent Visual Studio .NET 2005 from inserting the extra
space before the /at the end of the tag?



你真的*希望你的代码不符合XHTML标准,而且不需要b / b
跨浏览器兼容......?
http://www.w3schools.com/xhtml/xhtml_howto.asp



[在此回复中修剪了过多的新闻组列表。 ]


Nathan,
[ Excessive newsgroup list trimmed in this reply. ]

Nathan,

我没想到在/打破之前摆脱空间/>
XHTML规则。是吗?
I didn''t think getting rid of the space before the / was breaking the
rules of XHTML. Is it?



无需担心,可以在

" />"之前包含或遗漏空格。字符。


来自W3C发布的XML 1.1规范(XHTML基于XML):

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


....你可能会发现定义#44,它定义了一个空标签,如< BRas

如下:


EmptyElemTag :: =''<''名称(S属性)* S? ''/>''


这里,姓名是标签的名称,即BR,而S是标签的名称。代表一个白色的

空间,就像一个空格或制表符(一个或多个)。最后,有S?。和

后面跟着/>字符。 S后面的问号是一个

发生指标,意味着空白区可以存在,或者根本不存在




所以,两者都是< BR />和< BR />在规范上是正确的,

但后者可能更容易阅读(主观),而前者

占用的空间更少。


新年快乐!


-

问候,


先生Jani J?rvinen

C#MVP

芬兰赫尔辛基
ja * **@removethis.dystopia.fi
http:// www .saunalahti.fi / janij /

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 <BRas
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
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/


这篇关于在/&gt;中键入标记标记结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆