简体   繁体   English

Visual Studio使用XHTML标记关闭HTML5标记

[英]Visual Studio uses XHTML tag closing for HTML5 tags

Whenever I type out tags that don't require an end tag, Visual Studio adds a forward slash to it, as if they were XHTML. 每当我输入不需要结束标记的标记时,Visual Studio会向其添加正斜杠,就好像它们是XHTML一样。

I think this is unclean and annoying, and I'm hoping anyone can tell me how to fix or work around this issue. 我认为这是不洁净和烦人的,我希望有人能告诉我如何解决或解决这个问题。

It even happens when I complete <!DOCTYPE html with a > , and it'll form <!DOCTYPE html /> . 它甚至发生在我用<!DOCTYPE html >完成<!DOCTYPE html时,它将形成<!DOCTYPE html />

For completeness I'm posting this answer. 为了完整性,我发布了这个答案。 Although we're in 2014 now, with Visual Studio 2013 and HTML5 is getting more and more supported by the major browsers, Visual Studio still behaves the same as ... like always? 虽然我们现在在2014年,随着Visual Studio 2013和HTML5越来越受到主流浏览器的支持,Visual Studio的行为仍然像......总是一样吗?

The option is just a bit different than in 2010 I assume (based on accepted answer). 该选项与我假设的2010年略有不同(基于已接受的答案)。

使用/>完成XHTML样式的元素标记

What you could do is disable the auto closing tag option in Visual Studio. 您可以做的是在Visual Studio中禁用自动关闭标记选项。

Go to Tools >> Options >> Text Editor >> HTML >> Formatting 转到工具>>选项>>文本编辑器>> HTML >>格式

Uncheck the "Auto insert close tag" option. 取消选中“自动插入关闭标记”选项。

This will now allow you to type <br> (for example) and it won't auto-complete it as <br /> 这将允许您键入<br> (例如),它不会自动完成它<br />

For Visual Studio 2012, go to Tools -> Options -> Text Editor -> HTML -> Formatting and click Tag Specific Options . 对于Visual Studio 2012,请转到“ 工具” - >“选项” - >“文本编辑器” - >“HTML” - >“格式” ,然后单击“ 标记特定选项”

Under Default Settings -> Client tag does not support contents , set Closing tag to No closing tag . 默认设置 - >客户端标记不支持内容 ,将结束标记设置为无结束标记

设置界面的屏幕截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM