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


Rita Dunne
Rita Dunne
2,753 Points

difference between <br> and <br />

This post has led me to another question: how do I enter html into the forum and keep it from disappearing?

In the 'floats' section of CSS, there's a demonstration of the 'clear' property. For the clear property to work, Guil inserts a break after the paragraph in order to select it later to apply the clear property.

The html is:

        <img src="flag.png">
        <h4>Build a Simple Website</h4>
        <p>Smells Like Bakin' is a cupcake company in need of a website. This project will walk us through the basics of HTML and CSS from the very beginning. HTML and CSS are the structural and presentational building blocks of every website and will serve as the foundation for any web project. The Smells Like Bakin' cupcake company needs their website to work on tablets and phones. We will modify the code of their pre-existing website so that it is flexible and fits beautifully into a wide variety of screen resolutions and devices.</p>
        <br />

The CSS is:

br {
    clear: left;

However, the first time I did it I used <br> instead of <br /> and it didn't work. What's the difference between the two, and when do you use <br />? Why didn't <br> work since it's self-closing?

James Barnett
James Barnett
39,199 Points

Possibly topical:

The br element represents a line break. br elements must be used only for line breaks that are actually part of the content, as in poems or addresses. br elements must not be used for separating thematic groups in a paragraph.

source: http://html5doctor.com/element-index/#b

1 Answer

This stack overflow post is pretty famous/popular for this question:


To type code on the forum:


James Barnett
James Barnett
39,199 Points

Ernest Grzybowski - Thanks for linking to that post, before I saw that you did that, I had already edited Rita Dunne's post and fixed it's code formatting.