Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 220679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:57:43+00:00 2026-05-11T18:57:43+00:00

So if I have a HTML heading like this <h2>A Heading</h2> and I run

  • 0

So if I have a HTML heading like this

<h2>A Heading</h2>

and I run Edit -> Format Document it ends up looking like this

<h2>
    A Heading</h2>

why is this? It doesn’t do it to other block elements, but it does do it to other inline elements (eg <label>).

Update: To clarify, I mean why is this the default, not where are the settings to change this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:57:43+00:00Added an answer on May 11, 2026 at 6:57 pm

    It does it because those are its default settings. In older browsers, sometimes having the end tag of a block or inline element on a new line after the child element (effectively leaving whitespace, such as a non-breaking space or empty text node) affects how the page is rendered. I have had trouble with this before. For example, the following can have issues rendering correctly if your anchors have borders or padding:

    <a>
        <img src="..." />
    </a>
    

    Sometimes there would be additional spacing at the bottom of the link. Changing it to the following removes the additional spacing:

    <a><img src="..." /></a>
    

    Basically, the goofy formatting solves some rendering issues in browsers with shoddy CSS support like IE6. If you have IE6, look at this JSFiddle I created to illustrate the issue. There’s extra spacing at the bottom of the image where the anchor tags exist on their own lines.

    From Scott Guthrie’s blog:

    If you format a selection of markup and see that a close tag hasn’t been moved to a separate line – it is because there is no space between the end of the preceding markup and the terminating tag, and as such VS is being careful not to change it to avoid changing the rendering semantics.

    So as ugly as the formatting or output from the designer in Visual Studio can be, it is more likely to work in more browsers than would properly formatted markup (such as XHTML).

    To change the defaults for the formatting in Visual Studio, go to:

    Tools > Options > Text Editor > HTML > Format > Tag Specific Options...
    

    Under “Default Settings”, change the “Line Breaks” option to “Before and After” for both the Client and the Server “tag supports contents” options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this HTML block: <h2>heading A</h2> <p>paragraph 1 of A</p> <p>paragraph 2 of
I have some HTML that looks like this: <h2>Heading</h2> <div class='myClass'> <h2>Another Heading</h2> </div>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch
I have HTML like this: <a href=# class=modalInput glow rel=#newsletter >Newsletter!</a> This opens a
I have a HTML code like this: <pre><div class=post style=border-width:1px;border-style:solid> <div class=userpic style=width:70px;float:left> <img
I have this HTML heading: <h1>Time Matters&reg;</h1> (equals to: Time Matters®) I need a
I have a html like this : <h1> Headhing </h> <font name=arial>some text</font></br> some
I have a table structure for displaying posts like this: <table> <tr><td>heading of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.