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

Brett Cunningham
Brett Cunningham
3,251 Points

I'm need help finding exactly what I need to pass this challenge. Can someone take a look? I tried a variety of things.

It's the CSS Basic clearing floats challenge task 3 of 3

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



/* Clearfix ---------------------------------- */

.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" class="group">
        <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 -->
    </div>
        <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

Erik McClintock
Erik McClintock
45,783 Points

Brett,

For this challenge, you may notice that there is a .group class in your CSS with the property "clear: both;" declared in it. The third task is asking you to add a particular class to a particular HTML element in the index.html file to make it so it is cleared and doesn't collapse due to all of its child elements being floated.

Let me know if this helps to point you in the right direction, or if you need further assistance.

Erik

Brett Cunningham
Brett Cunningham
3,251 Points

Yes it's asking to add the appropriate class (group) to the div on line 9. On my html page there wasn't a div so I created one. Which div do I add the group class to and where do I end the div tag?

Erik McClintock
Erik McClintock
45,783 Points

Brett,

There is a div with the class .secondary-content in this HTML file, noted below with a comment (as you said, on line 9. You say your HTML file doesn't have this?)

<!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"> <!-- BRETT - HERE IS THE .SECONDARY-CONTENT DIV -->
      <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>
Brett Cunningham
Brett Cunningham
3,251 Points

I think I may shifted it down on accident if it was there by default. I think I already tried adding a group class to that "secondary-content t-border" div but I will try again if that's what I'm supposed to do.

Erik McClintock
Erik McClintock
45,783 Points

Yes, that is where you need to add it. I noticed in the HTML that you posted that you created another class attribute: DO NOT DO THIS! You simply need to add the class (separated from the others by a space) to the existing attribute of that element. Notice how right now it has two classes listed there: "secondary-content" and "t-border". Simply put a space after the "t-border" class, add your "group" class, and you'll be good to go!

Erik

Brett Cunningham
Brett Cunningham
3,251 Points

Ooooooooooh :) Thanks!!!! It works now.

Erik McClintock
Erik McClintock
45,783 Points

My pleasure!

Happy coding!

Erik