Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

HTML 5: Is it <br>, <br/>, or <br />?

I've tried checking other answers, but I'm still confused — especially after seeing W3schools HTML 5 reference.

I thought HTML 4.01 was supposed to "allow" single-tags to just be <img> and <br>. Then XHTML came along with <img /> and <br /> (where someone said that the space is there for older browsers).

Now I'm wondering how I'm supposed to format my code when practicing HTML 5.

Is it <br>, <br/> or <br />?

Answer*

Draft saved
Draft discarded
Cancel
7
  • 9
    Well formed HTML is not XHTML. Commented Mar 22, 2018 at 13:33
  • 4
    XHTML is well-formed HTML by definition. XHTML follows the rules of XML, according to w3schools "XML is a markup language where documents must be marked up correctly (be "well-formed")... ...By combining the strengths of HTML and XML, XHTML was developed. XHTML is HTML redesigned as XML." (see w3schools.com/html/html_xhtml.asp) Commented Mar 23, 2018 at 14:44
  • 5
    HTML can be well formed, but not be valid XML. W3Schools isn't always the most authoritative reference. Commented Mar 23, 2018 at 19:32
  • 3
    <br> and <hr> are perfectly valid and well formed HTML. They are not valid XML tags. The HTML specs under HTML syntax says that void elements (like <br> or <hr>) may have a / character immediately preceding the final >. But it has no effect. It is ignored if it is there. If the / was a preferred piece of the syntax, the standard would say should rather than may. Commented Mar 23, 2018 at 20:10
  • 4
    @jmarkmurphy, I think that maybe you are unfamiliar with the term "well-formed" being a technical jargon term to refer to the requirement to the standards of XML and XHTML that all tags must have closing tags and must be nested in the proper order. <hr> and <br> do not meet the requirements of XML and XHTML because they do not have closing tags, eg: <br /> or <br></br> are valid, <br> is not valid XHTML or XML. HTML, of course, does not have the well-formed requirement so <br> and <hr> are valid in HTML only. Commented Mar 26, 2018 at 14:35

lang-html

AltStyle によって変換されたページ (->オリジナル) /