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

Hazuki Tran
Hazuki Tran
6,676 Points

Specified class for clearing float (in HTML)

"In the preview, notice how the floats made the parent container's height collapse. In the HTML file, give the .secondary-content div the specified class for clearing floats."

I'm not sure exactly what the challenge above is asking of me. I thought the class name can be anything you find relevant?

style.css
/* Complete the challenge by writing CSS below */
.content-lodging {
  float: right;
}

.content-traveling {
  float: left;
}



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

.group:after {
  content: "";
  display: table;
  clear: both;
}
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"> 
      <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>

7 Answers

Hi Hazuki,

The class is already set up in style.css under the comment:

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

You just need to assign that class to the div with a class of secondary-content in your index.html.

Hope that helps.

-Rich

No problem :)

Thanks a lot...

how Rich

Guillermo mendoza
Guillermo mendoza
6,426 Points

It does not work for me what would the code look like?

Hi Guillermo mendoza / Tapiwa Chinembiri ,

Sorry for the delay. The class already set up is .group. This would mean line 9 of index.html changing from:

<div class="secondary-content t-border">

to:

<div class="secondary-content t-border group">

Hope that helps.

-Rich

Elle Kasser
Elle Kasser
4,605 Points

I also have a question - why doesn't simply adding class="group" work?

How is <div class="group" class="secondary-content t-border"> different from <div class="group secondary-content t-border">?

Are we adding three different classes to the div in the second example?

Its a lot simple when you do what Rich said.

and I think There can be only 1 class on the div element.

Thanks, glad it worked for you Channon Hall. Just noticed the answer has been marked down and not entirely sure why.

Yeah....not sure too :|

I made the same mistake. it makes sense now. <div class="secondary-content t-border group"> is the right answer like rich said. I was adding group outside of these "" <div class="secondary-content t-border" group> small stuff makes a difference

<div class="secondary-content t-border">

When we were doing it through the video though I did it like this: <div class="secondary-content t-border" class="group"> but in the code challenge that wouldn't work. I don't understand why it worked before but not for this.

Learning coding
seal-mask
.a{fill-rule:evenodd;}techdegree
Learning coding
Front End Web Development Techdegree Student 9,937 Points

When I put : <div class="secondary-content t-border group">

I get Task two is not longer passing. So I go back to task two en click recheck work and I pass for taks 2.

Then I put <div class="secondary-content t-border group"> again and I am redirected to task two again.

How do I pass this task. It seems like the code is wrong. Thanks.

I'm having the same issue.

I think the code is wrong and the :: is messing everyone up. I left the double colon and I passed the code challenge.

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

HTML: <div class="secondary-content t-border group">

I cannot get it for nothing ive been stuck on it for a couple days