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 Selectors Advanced Selectors Pseudo-Elements Challenge

Code Challenge: Pseudo-Elements Challenge Stage 3 Advanced Selectors

Can anyone assist me in with these 1 of 4 tasks? having trouble Challenge Task 1 of 4

Let's use pseudo-elements to create a progress bar from a single element. First, in the top .progbar selector, add the pseudo-element that will insert content after the progbar element.

Challenge Task 2 of 4

In the same rule, add the property that lets us insert content into an element. The value should be an empty set of quotes.

Challenge Task 3 of 4

Next, in the second .progbar selector, add the pseudo-element that will insert content before the progbar element. Don't forget to write the content declaration on line 13.

Challenge Task 4 of 4

Finally, create a new rule that will insert a pseudo-element after an a element. As the content value, define a CSS function that will insert an href attribute's value as content.

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

.progbar {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
    background-color: #5ece7f; 
}

.progbar {

    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    position: absolute;
    left: 49%;
    top: -9px;
    background-color: #7dd898; 
}

.progbar {
  height: 6px;
  border-radius: 3px;
  background: #d6d7d9;
  position: relative;
  margin-bottom: 3.875em; 
}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Selectors</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="page.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="progbar"></div> 
    <a href="http://teamtreehouse.com">Check out the URL: </a>
</body>
</html>

Nevermind you guys. I Passed it but you can work it out for the others who may have trouble with it . Thanks

10 Answers

Garrett Levine
Garrett Levine
20,305 Points

You're having trouble with the first task or all of the tasks?

The first task is asking you to change the entire selector from .progbar to something that would insert content after the progress bar.

this looks like this;

  .progbar::after {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background-color: #5ece7f;
}

After this, all before and after psuedo elements require you to have a certain attribute within their declaration, or else they will not run. They need something to inseert before or after, and this is done through adding the "content" attribute.

I think the remaining tasks may become easier after solving these two.

Thanks . :)

task 1 to 4

.progbar::after { content: ""; display: block; width: 50%; height: 100%; border-radius: inherit; background-color: #5ece7f; }

.progbar::before{ content:""; display: block; width: 24px; height: 24px; border-radius: 50%; position: absolute; left: 49%; top: -9px; background-color: #7dd898; }

a::after { content: attr(href): }

.progbar { height: 6px; border-radius: 3px; background: #d6d7d9; position: relative; margin-bottom: 3.875em; }

how do solve task 4 on this code challenge

lindsey millen
lindsey millen
1,936 Points

I just figured this out!

.progbar a::after { content: attr(href); height: 6px; border-radius: 3px; background: #d6d7d9; position: relative; margin-bottom: 3.875em; }

how do i solve task 3

um stuck with first challenge

Richard Targett
Richard Targett
4,960 Points

Google deserves the 12 points I got for completing these challenges. It led me here. Mind you I got the first 3. This is an interesting one though. Thanks for the tips. I understand more of it though since I went and implemented the ::befores into the site Im working on and I totally got it from here...

...Thanks to treehouse...and you...and google...and this thread XD

Hi,

I am particularly stuck with Challenge 2, I can't really work it out.

Can someone help me out?

John Hofford
John Hofford
6,990 Points

Frank, it's actual a simple solution that made me mad once I got it.

You literally just need to add the style property for your Content and then leave the properties blank.

SPOILERS Below just in case you can't solve it.

.progbar::after { content: ""; display: block; width: 50%; height: 100%; border-radius: inherit; background-color: #5ece7f; }

Wietse Wierda
Wietse Wierda
1,403 Points

lol thx john. apparently team treehouse does no accept singleqoutes

Anain Roibal
Anain Roibal
4,532 Points
.progbar::after {
  content: ""
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
background-color: #5ece7f; 

.progbar::after { display: block; width: 50%; height: 100%; border-radius: inherit; background-color: #5ece7f; }

Bao Tran
seal-mask
.a{fill-rule:evenodd;}techdegree
Bao Tran
Front End Web Development Techdegree Student 18,959 Points

For Challenge 3 is just like step 1 but with value "before" instead of after.

For Challenge 4 linsey had answer it.

.progbar a::after { content: attr(href); }

this gave me trouble thanks guys this really helped ^_^