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 Accessibility Websites CSS: Part 3

Confused about float: left vs. float: right

Reference the following code:

#widget_pic {
float: left;
width: 30%;
margin-left: 5%;
height: 300px;
}

#content {
width: 65%l
float: left;
}

When Nick is styling the widget pic, he uses the float: left property. But, the widget appears on the right side of the page. I'm assuming this is because he also floats the content div to the left and it pushes the widget to the right of the page. Is this normal practice when styling pages with essentially two columns? Why not just float: right the #widget_pic image?

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

I believe it;s because both the float widget and the content are both being floated left, so both elements are being taken out of normal document flow.

Also on the second style you're not terminating the style rule properly.

Try the following; see if it makes a difference. :-)

#widget_pic {
float: left;
width: 30%;
margin-left: 5%;
height: 300px;
}

#content {
width: 65%;
}

Jonathan my question is, WHY are they both being floated left? He wants the widget pic on the right side of the page, so why not apply float: right to the widget pic? It ends up on the right side of the page anyway, even though it is floated left. It's just confusing...my question, put another way: if two elements are being floated side by side, does it not matter which direction you float them?