HTML – What do I use: <br>, <br/>, or <br /> ?

This has been bugging me for quite some time now and since I started using HTML a long time ago in a galaxy far far away <br> was the tag format of choice. Actually it was the only choice… Then I started seeing  <br>, <br/>, and <br /> sprinkled everywhere. It is amazing how having to type one extra keystroke for that one slash can be so annoying. So it’s good to know that according to:

http://w3c.github.io/html-reference/syntax.html#void-element

Void elements (such as br tags) only have a start tag; end tags must not be specified for void elements.

Optionally, a “/” character, which may be present only if the element is a void element. So you can use <br> or <br/> or <br />

So unless you are trying to satisfy other languages such as XHTML or XML generating HTML, you can use any one of the above and it should still validate (https://www.w3.org/)

yay…

Leave a Reply

Your email address will not be published. Required fields are marked *