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

时间:2022-03-05 08:42:25

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

3 个解决方案

#1


16  

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

这将允许您键入
(例如),它不会自动完成它

#2


17  

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年略有不同(基于已接受的答案)。

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

#3


1  

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.

在默认设置 - >客户端标记不支持内容,将结束标记设置为无结束标记。

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

#1


16  

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

这将允许您键入
(例如),它不会自动完成它

#2


17  

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年略有不同(基于已接受的答案)。

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

#3


1  

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.

在默认设置 - >客户端标记不支持内容,将结束标记设置为无结束标记。

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