freeCodeCamp Challenge Guide: Use CSS Selectors to Style Elements

freeCodeCamp Challenge Guide: Use CSS Selectors to Style Elements
0

Use CSS Selectors to Style Elements


Problem Explanation

CSS selectors are widely used to apply styling to all instances of a particular element.

To apply the color purple to all the h2s on the page, you can define the following CSS inside a <style></style> block.

h2 {
  color: purple;
}

This will apply the color purple to all <h2> headings. If you are using the style="color: purple" attribute on each <h2> element, you can remove it and instead define it in a single place inside a <style></style> block.

4 Likes

Hello,

I am having a problem with using CCS Selectors to Style elements. Here is a snippet of everything I’ve done. I only have one X and I don’t know how to solve it.

4 Likes

I am having the same issue as well. Some help would be greatly appreciated.

1 Like

Same. This needs to be fixed guys. We’ve clearly followed everything.

1 Like

Here’s the solution guys:
< style>
h2 {color: blue;}
< /style>

< h2>CatPhotoApp< /h2>

< p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.< /p>

I had to make spaces inside tags to could show you the code itself, just remove the space and should be good.

17 Likes

This is not the solution on mine.
Anyone know how to rectify or move on to next task?

3 Likes

Hey XanderHall,

I see from your code in lines 2 + 3 that it looks a little jumbled, I had a similar issue in the placement of the CSS element. I would reset the code and keep CSS style element at the top and away from the actual (h2>CatPhotoApp</h2) as the CSS element will point to this when you declare it, so it should look a little like the code above and you’ll be rockin’!

Keep on keepin’ on :slight_smile:

2 Likes

I have completed this challenge with the same solution that many other users have come to submit.

The one issue that I ran into that may help others here is that the challenge sometimes does not recognize a correct solution when pasting in from an external text editor. I ran into this as I like to edit with an external text editor because it will auto-complete the tags. However, when pasting into the browser and submitting it is incorrect. I instead had to type the solution manually in the browser and submit, then it accepted as correct.

Hope this helps,

-Crypt.

1 Like

you have deleted your actual h2 element meaning youve made nothing blue.

anyone have an example of a period is? lesson says that a css starts with a period and a class declaration doesn’t and I’m confused on the difference of the 2.

I am just as confuse especially since I follow the lesson instruction accordingly. Is there a way that we can contact a Freecodecamp.org admin staff directly with questions pertaining to this lessons?

1 Like

Spacing seems to be an issue here, which seems off putting. Nonetheless it accepted my answer. :laughing:

1 Like

the problem here is with your h2 element…it has no opening i.e