Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

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:

<div>
        <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 />
    </div>

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:

http://stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br

To type code on the forum:

https://teamtreehouse.com/forum/how-to-type-code-in-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.