Al Kepp
Al Kepp

Reputation: 5980

<br> instead of <br/> in Visual Studio

I use Visual Studio for teaching HTML. We use HTML 4.01 Transitional. Visual Studio defaults to XHTML 1.0, and I need to solve one problem with a typical difference among these two HTML standards: Whenever we enter <br> or <hr>, it is automagically changed to <br /> or <hr /> respectively. This is great for XHTML, but unwanted when working in HTML 4.01 mode.

So how to turn off this automagical feature? We use mainly Visual Studio 2010, and sometimes also 2012 and 2008.

(I know how to easily switch validation to HTMl 4.01 mode, but it still puts slashes to each <br>, <hr> etc.)

Upvotes: 8

Views: 2759

Answers (4)

Aron Boyette
Aron Boyette

Reputation: 957

For those writing CSHTML and have this problem, I fixed it by modifying settings under...

Tools -> Options -> Text Editor -> Razor (ASP.NET Core) - Advanced
  • Format On Type = False
  • Auto Insert Closing Tag = False

enter image description here

Upvotes: 0

Langdon
Langdon

Reputation: 20073

Old question, but even more relevant today.

In Visual Studio 2015, Tools, Options:

Tools | Options in Visual Studio 2015

Upvotes: 2

Tim M.
Tim M.

Reputation: 54407

Tools -> Options -> Text Editor -> HTML -> Formatting -> Tag Specific Options

You may define behavior for each individual tag. Hit CTRL + K + D to reformat the document and you should see the change.

Specific Tags

enter image description here

Alternative Method (All Tags)

enter image description here

Upvotes: 8

Ravindra Bagale
Ravindra Bagale

Reputation: 17675

Tool -> Options -> Text Editor -> HTML -> Format -> Tag Specific Options... -> Client HTML Tags -> br

Upvotes: 0

Related Questions