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

CSS

pietro capriata
pietro capriata
18,066 Points

Why in the the-float-clearfix we need to add "content = " "" in the class group::after?

It is not clear why! thx

3 Answers

Markus Ylisiurunen
Markus Ylisiurunen
15,034 Points

Hi!

The idea behind "clearfix" is simple. The problem "clearfix" fixes is that if there is only floatet content in the wrapper, wrapper looses it's height. Clearfix forces the wrapper to be the same height as its content.

group::after is there because it adds content after all the elements in the wrapper. And we don't want to put anything visible to our page which we don't want visiters to see, so we just put there a single space. content: " " adds single space to the end of the wrapper so it forces the wrapper to be the size as its content is.

Markus Ylisiurunen
Markus Ylisiurunen
15,034 Points

Maybe this will clear it a little bit up. I made a simple JSFiddle project and you'll be able to see what clearfix does.

Here is a link to it: JSFiddle

Try to experiment with it and understand what it does. Try to change every property in css and see what they do.

Hopefully this helps to understand it.

pietro capriata
pietro capriata
18,066 Points

thx so .. the menu are float, but the " " is not float and appear after the "menu items" and the "clear fix" tell at the browser " the " " is after the menu, but because is not float is normal and so i need to make a space to content it"? right?