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 trialHadi Farhat
Courses Plus Student 7,102 Pointsrelation between float and width
do we always set the width of an element to 100% when we float that element to the left or right ?
1 Answer
bobcat
13,623 PointsI see in the video that Nick has used a width of 100% for the header because he wanted the header to cover the entire width of the screen in one large block, but if he wanted it to take up a different amount of space he could have specified any different width he liked. It doesn't always have to be width 100% - It depends of what area of the page you are trying to take up with your div / header or element etc..
Hope that helps.
bobcat
13,623 Pointsbobcat
13,623 PointsI think if you are trying to float a div to the left and wanted it to take up half the width of the page so you could float another div next to it, you would set each div with a width of 50% - Or if you wanted a 3 column layout each div would have a width of 33%. I think margin and padding will affect the width of each div and might then take up more than 100% of the page width thus pushing the next div down to the next line.
I think that is the kind of answer you were looking for, but if not I will try to help you further.