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

Timothy Delaney
Timothy Delaney
2,785 Points

Trying to apply a clearfix to the footer. What am I doing wrong?

???

style.css
/* Complete the challenge by writing CSS below */



.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
.footer-nav {
  float: left;
}
.logo {
  float: right;
}
.footer-nav li {
  float: right;
}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Getting Started with CSS Layout</title>
    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
    <body>
    <div class="container">
        <footer>
      <div class=footer clearfix>
            <img class="logo" src="city-logo.svg" alt="logo">
            <ul class="footer-nav">
                <li><a href="#">Ice cream</a></li>
                <li><a href="#">Donuts</a></li>
                <li><a href="#">Tea</a></li>
                <li><a href="#">Coffee</a></li>
            </ul>
            <p class="copyright">&copy;2015 The Best City.</p>
        </footer>
    </div>
    </body>
</html>

3 Answers

Steven Parker
Steven Parker
231,269 Points

You don't need to add a new div inside the footer, just apply the class directly to the footer element.

And remember to enclose your class name(s) in quotes:

        <footer class="clearfix">
Timothy Delaney
Timothy Delaney
2,785 Points

That did it. Thanks for your help.

Hi Timothy,

In this task, it asks you target the footer tag, not the div with a class of footer. So, in your HTML (don't need to touch your CSS for this one), you need to add a class of "clearfix" to the opening footer tag:

<footer>

You add a class to a tag with this syntax:

<footer class="your-class">

Hope that helps,

Ede

Ryan Peacan
Ryan Peacan
26,764 Points

It's difficult to tell what you're trying to accomplish due to not knowing what page.css brings to the table, but I did notice some issues with the index.html file, hopefully it helps:

<div class="container">
      <footer>
            <div class="footer clearfix"> <!-- This line didn't have quotes around the classes -->
                  <img class="logo" src="city-logo.svg" alt="logo" />
                  <ul class="footer-nav">
                        <li><a href="#">Ice cream</a></li>
                        <li><a href="#">Donuts</a></li>
                        <li><a href="#">Tea</a></li>
                        <li><a href="#">Coffee</a></li>
                  </ul>
                  <p class="copyright">&copy;2015 The Best City.</p>
            </div> <!-- This div wasn't closed. whoops! -->
      </footer>
</div>