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 trialMUZ140041 Machona Machona
5,274 PointsCreate a rule using the selector that targets an element only if its ID matches the hash in a URL.
Give its background color to tomato
<!DOCTYPE html>
<html>
<head>
<title>More Pseudo-classes</title>
<link rel="stylesheet" type="text/css" href="page.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<ul>
<li><a href="#s1">Section 1</a></li>
<li><a href="#s2">Section 2</a></li>
</ul>
<div id="s1">
<h2>Section 1</h2>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex.
</div>
<div id="s2">
<h2>Section 2</h2>
Integer laoreet urna ut est cursus nec tristique elit vestibulum. In hac
habitasse platea dictumst. Quisque pharetra odio nec urna lobortis sed
ultrices dolor posuere. Sed nec nisl id augue congue euismod.
</div>
</body>
</html>
/* Write your CSS code below */
:root {
background-color:lightblue
}
Wayne Priestley
19,579 PointsYou also need to set the colour to tomato, not lightblue.
Marcus Parsons
15,719 PointsWayne,
The first part of the challenge is, in fact, to set the background-color
property of the :root element to lightblue.
1 Answer
Brendon Conradie
3,130 PointsYou have to use a CSS3 pseudo selector to turn the link's background color into another color namely tomato. I find the selector in question to not be too useful, not too fond of the jumpiness which is the default behaviour, but it's totally acceptable from a users stand point. Although you could certainly use some animations to highlight the area that you have targeted
:)
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsHey MUZ140041 Machona,
If you're having trouble finding the selector to use in this instance, go back to the video and listen to what Guil says starting at about 1:05. He goes over the selector you're looking for in detail. You also should put a semi-colon at the end of your property declarations, because adding other properties to your selector without giving them semi-colons will cause the CSS to not load properly i.e.
If you can't pass the challenge with the code you come up with, post back here and we will help you out.
I don't want to give you the answer straightaway because we don't learn anything that way. :)