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
2
  • @Julix Indeed, why the down-votes? Tthis is one of the few correct Answers on this page. HTML5 absolutely is XML conforming, optionally, and in XML syntax, a single tag must be closed with the slash. How can such simple facts be so misconstrued when written in black-and-white in the spec. Commented Aug 5, 2018 at 1:23
  • 3
    @BasilBourque, I think this can be given by that mainly the answer's 1st sentence is overly brief / misleading: "<br> is sufficient but in XHTML <br /> is preferred ..." => one could infer that <br> might be used in XHTML, which is not truth. Commented Jun 12, 2022 at 11:35

lang-html

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