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 Basics (2014) Basic Layout Floats

Lacey Jayne
Lacey Jayne
3,519 Points

I can't figure out what I am doing wrong! I want to clear:both; but it's saying I am not correctly calling out the div

How do I call out the div? .secondary-content ?

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



/* Clearfix ---------------------------------- */
.secondary-content{
  clear: both;
}

.group:after {
  content: "";
  display: table;
  clear: both;
}

.content-lodging{
  float: right;
}

.content-traveling{
  float: left;
}
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body> 
        <div class="secondary-content t-border"> 
      <div class="content-lodging">
        <img src="resort.jpg" alt="Resort">
        <h3>From Tents to Resorts</h3>
        <p>
          Lake Tahoe is full of wonderful places to stay. You have the ability to sleep in the outdoors in a tent, or relax like a king at a five star resort. Here are our top three resorts:
        </p>
        <ul>
          <li><a href="#hotels">Lake Tahoe Resort Hotel</a></li>
          <li><a href="#resorts">South Lake Tahoe Resorts</a></li>
          <li><a href="#lodging">Tahoe Ski Resort Lodging</a></li>
        </ul>       
      </div>

      <div class="content-traveling">
        <img src="mtn-landscape.jpg" alt="Mountain Landscape">
        <h3>Pack Accordingly</h3>
        <p>
          One of most important things when it comes to traveling through the great outdoors is packing accordingly. Here are a few tips:
        </p>
        <ol>
          <li>Bring layers of clothing</li>
          <li>Pack sunscreen</li>
          <li>Carry extra water just in case</li>
          <li>Pack light</li>
        </ol>
      </div>
        </div><!-- End .secondary-content -->

        <footer class="main-footer">
            <p>All rights reserved to the state of <a href="#">California</a>.</p>
            <a href="#top">Back to top &raquo;</a>
        </footer>
  </body>
</html>

3 Answers

Jeff Lemay
Jeff Lemay
14,268 Points

You've used the clear property correctly but the challenge did not want you to do that. They are asking you to add a class for clearing floats to the HTML file. You'll just add the additional class to the element with a class of secondary-content.

Lacey Jayne
Lacey Jayne
3,519 Points

thank you! I added group to the div and that worked; I forgot that HTML can do that! I appreciate the quick help!

geoffrey
geoffrey
28,736 Points

In fact, you don't need to target the secondary content as you did. You should remove the secondary-content class and keep your css this way.

.group:after {
  content: "";
  display: table;
  clear: both;
}
.content-lodging{
 float:right; 
}
.content-traveling
{
 float:left; 
}

As you can see, there is already a class that was already set to clear floats, which is called group. So all you need to do, is apply this class on the appropriate element in the html, in this case, It's the div which contains both floating elements (content-lodging & content-traveling). This div is the one where the secondary-content class is applied.

 <div class="secondary-content t-border group">
<!--floating elements here-->
</div>