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 trialanonymous123
5,794 Pointshorizontal navigation with floats
"With floats, we don't have to worry about the the extra whitespace that can appear when using inline or inline-block display." "Floated elements will sit adjacent to each other regardless of the HTML whitespace between them."
we never changed the display value of any of the elements we worked with. why are they acting like inline block elements? Im very confused.
1 Answer
Michael Shields
12,650 PointsThe <a> elements that are descendants of the <h1 class="name"> and the <ul class="main-nav"> elements are declared as block-level display in our style.css file.
When we declare a float value we are manipulating the normal document flow. That floated element now accepts all block-level element values like width, height, padding, and margin, BUT the floated element doesn't exist on it's own line (i.e. doesn't create HTML whitespace before and after the element like a block-level <div> would) and the surrounding content flows around it, behaving like an inline element would.