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 trialHazuki Tran
6,676 PointsSpecified 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?
/* Complete the challenge by writing CSS below */
.content-lodging {
float: right;
}
.content-traveling {
float: left;
}
/* Clearfix ---------------------------------- */
.group:after {
content: "";
display: table;
clear: both;
}
<!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 »</a>
</footer>
</body>
</html>
7 Answers
Rich Bagley
25,869 PointsHi 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
Guillermo mendoza
6,426 PointsIt does not work for me what would the code look like?
Rich Bagley
25,869 PointsHi 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
4,605 PointsI 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?
channonhall
12,247 PointsIts a lot simple when you do what Rich said.
and I think There can be only 1 class on the div element.
Rich Bagley
25,869 PointsThanks, glad it worked for you Channon Hall. Just noticed the answer has been marked down and not entirely sure why.
channonhall
12,247 PointsYeah....not sure too :|
kaz eden
2,413 PointsI 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
MUZ140875 Joseph Chivasa
7,758 Points<div class="secondary-content t-border">
tifferz
7,948 PointsWhen 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
Front End Web Development Techdegree Student 9,937 PointsWhen 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.
Dakota Neff
2,480 PointsI'm having the same issue.
Andres Perez
9,130 PointsI 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">
Howard Lowry
1,359 PointsI cannot get it for nothing ive been stuck on it for a couple days
Hazuki Tran
6,676 PointsHazuki Tran
6,676 PointsThanks Rich ;)
Rich Bagley
25,869 PointsRich Bagley
25,869 PointsNo problem :)
Joy Ahmed
Courses Plus Student 9,687 PointsJoy Ahmed
Courses Plus Student 9,687 PointsThanks a lot...
Tapiwa Chinembiri
6,285 PointsTapiwa Chinembiri
6,285 Pointshow Rich