简体   繁体   中英

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.

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

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

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

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

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 .

设置界面的屏幕截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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