Visual Studio uses XHTML tag closing for HTML5 tags

最后都变了- 提交于 2020-01-10 17:30:52

问题


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.

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


回答1:


What you could do is disable the auto closing tag option in Visual Studio.

Go to Tools >> Options >> Text Editor >> HTML >> Formatting

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 />




回答2:


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?

The option is just a bit different than in 2010 I assume (based on accepted answer).




回答3:


For Visual Studio 2012, go to Tools -> Options -> Text Editor -> HTML -> Formatting and click Tag Specific Options.

Under Default Settings -> Client tag does not support contents, set Closing tag to No closing tag.



来源:https://stackoverflow.com/questions/6968052/visual-studio-uses-xhtml-tag-closing-for-html5-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!