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 trialBryce Chua
5,429 PointsCode Challenge Task 2: Selectors - Beyond the Basics
Am I missing out something here? Please help, thanks in advance!
It looks like we need to decrease the space between h2 elements and the paragraph that immediately follows. Create a new selector that targets p elements that are adjacent siblings of an h2. Then, set the top margin to .5em.
Bummer! Are you setting the correct 'margin-top' value?
.main-nav > li {
display:inline-block;
margin-left: 20px;
}
.h2 + p {
margin-top: .5em;
}
<!DOCTYPE html>
<html>
<head>
<title>Selectors</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="main-header">
<h1>My Blog</h1>
<ul class="main-nav">
<li><a href="#">About Me</a></li>
<li><a href="#">My Work</a></li>
<li><a href="#">Get In Touch</a></li>
</ul>
</header>
<div class="main">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut et feugiat libero. Cras ut fermentum nisi. Nullam mattis, ipsum commodo laoreet volutpat, augue eros ornare lorem, eu interdum leo massa a nibh.</p>
<p>In vel semper lorem. Pellentesque in quam pulvinar, fringilla justo ac, accumsan ante. Etiam in malesuada lacus.</p>
<div class="post">
<h2>Post Heading</h2>
<p>Nulla eu vestibulum mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer blandit ex velit, vitae consequat quam viverra at... <a href="#">read more »</a></p>
</div>
<div class="post">
<h2>Post Heading</h2>
<p>Aliquam cursus tempor molestie. Phasellus nec mattis elit. Sed fringilla laoreet magna, sodales vulputate leo auctor eu. Cras scelerisque laoreet faucibus. Proin cursus, metus... <a href="#">read more »</a></p>
</div>
</div>
</body>
</html>
9 Answers
Ayoub AIT IKEN
12,314 Pointsh2 is a Tag, not a class :) . remove the dot before the h2 rule
MD Fahim Hassan
Full Stack JavaScript Techdegree Student 7,148 Points.main-nav > li {display: inline-block; margin-left: 20px; }
h2 + p { margin-top: .5em;}
MUZ140526 Alex Mawene
2,687 Points.main-nav > li { display:inline-block; margin-left: 20px; }
.h2 + p { margin-top: .5em; }
geoffrey
28,736 PointsYes, Ayoub is right !
Bryce Chua
5,429 PointsIt works fine now. Thank you!
MUZ140993 Angelinah Chiwonerwa
5,907 Pointsh2 is not a class ,i realised that too ..had made a mistake
Hossein Kamalifar
Courses Plus Student 12,016 Pointsh2 + p { margin-top: .5em; }
Aungkul Aungkulwattanachai@gmail.com
6,317 PointsHi guys ,
I am just wondering is that h2 + p and p + h2 is that the same ??
Thank you
Rodney Nyasha Mafuta
19,256 Points.h2 + p { margin-top: .5em; }
Ary de Oliveira
28,298 PointsAry de Oliveira
28,298 Pointscool you all ok .