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 CSS Layout Basics Page Layout with the Float Property Footer Layout with Floats

Sandeep Krishnan
Sandeep Krishnan
9,730 Points

In the code challenge for float why did I have to write the class twice ? Isn't it violating principles of DRY

To the question of moving the list item in Footer Nav .to left. I had to write the write the .footer class twice, Is this necessary when the elements I am targeting below are the same?

.footer-nav{ float:left; } .footer-nav li{float:left;}

2 Answers

In this case, you are selecting two different elements. First, you are targeting just the element with the class of footer-nav. Second, you are targeting the list item elements that are within the .footer-nav. The first positions the footer to float left in relation to other elements around it. The second positions the list item elements to float left in relation to other elements around them, but inside of the the .footer-nav. In this case, you are repeating that one class name, but you should look at the entire selector when it comes to css. If you had two rules that used the exact same selector, then it would possibly be a violation of DRY coding. For example: .footer-nav li {float: left} then later .footer-nav li {color: blue}. These two rules could be combined into one because they have matching selectors.

I hope this helps!

Sandeep Krishnan
Sandeep Krishnan
9,730 Points

thanks Jeseekia, much appreciate it.