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.

CSS Responsive Layouts Media Queries Understanding Breakpoints

hi can someone explain this css code plz ?

/************************* Clearfix *************************/

.clearfix:before, .clearfix:after { content: " "; display: table; }

.clearfix:after { clear: both; }

.clearfix { *zoom: 1; }

can someone tell what is the :before for and the *zoom:1 ? thanks you

2 Answers

Steven Parker
Steven Parker
210,425 Points

The ":before" selector (more commonly written with two colons, "::before") creates a pseudo-element as the first child of the otherwise selected element. See this MDN page for more information.

The "zoom" property affects the magnification of an element, and a value of 1 means "no magnification". But note that this property is non-standard and is not recommended for use on production sites Consider using "transform: scale()" (details on this MDN page) instead.

In addition to the non-standard "zoom" property, this code appears to have an issue in the definition of ".clearfix::before" being incomplete.

In addition to what Steven said, the * before zoom indicates some CSS hack for .. I think older IE versions (8 or earlier, iirc) So that line *zoom: 1; is only intended to be read by the older IE (rip).