Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Basics Images, Text and Links Creating Breaks in Content

Brian Pitts
PLUS
Brian Pitts
Courses Plus Student 3,826 Points

What is appropriate HTML5 syntax: <br> or <br/>?

Interestingly, even the MDN docs show examples on the same page when discussing their use in <address> as line breaks: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address

I've read that you can use either, but <br/> is a remnant of the HTML4 spec that included xhtml (https://stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br) and at W3 (https://www.w3schools.com/tags/tag_br.asp)

2 Answers

David Moorhead
David Moorhead
18,005 Points

"current best practices" since nothing is ever static in this world :)

No truer ^ words!

David Moorhead
David Moorhead
18,005 Points

Hi, Brian,

Good question. I tend to think in terms of best practices rather than "appropriate," so, with my tried-and-true "best practices" exercise, I replaced a <br> in the footer with both <br /><br/> side-by-side in some recent HTML markup. I ran the file through W3c's validator, and the markup resulted error free.

Well, that was good to know. :smile:

Thoughts?

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

Better to close it.

That's a 'best' practice considering frameworks like React etc...

MDN closes it as well.

Even though it's opinionated, I think it's best to close it.

Brian Pitts
Brian Pitts
Courses Plus Student 3,826 Points

I would just add "current best practices" since nothing is ever static in this world :)