I have no idea what's wrong with my simple code!

This is a little worrying that I cannot do something so simple. I am new to coding so please be nice.

Welcome

.h1{
background-color: green;
}

Hello there!
What does the task in hand want you to do? If it requires you to give the class name h1 a background colour then your code is ok, if it asks you to apply the background colour to the h1 element then your code is not right.

2 Likes

Applying the background colour to the h1 element, I also want to learn how to change the background colour too.

Tips on implementing information while coding permanently so that I do not forget it would be greatly appreciated.

Hi @nizarali.yt

h1 is a predefined element, not a class, do not use a dot.
The dot prefix is used for classes.

Happy coding

3 Likes

Welcome

h1{
background-color: green;
}

Unfortunately it doesn’t work, very disappointing…

Thanks for the reply tho greatly appreciated.

Is there an error being thrown? This will help us determine if there are missing requirements, if no error is thrown then what do the instructions ask you to do, you might have missed something.

1 Like

I genuinely have no idea what’s wrong and I thought I need to go back to the basics.

Ill go through a YouTube video and see what happens.

Thank you for your concern.

Is this a part of the freecodecamp curriculum?

No, I just find out that people here are really helpful, I used freecodecamp for myself and I learned a lot, but I was in tutorial hell, so I’m trying to escape it.

Ok, I get it, but for us to help we need to know what you want to achieve, what do you wish to accomplish with your code?

1 Like

StephenMutheu answered your error. The dot method is only used for classes so the correct css styling would be:

h1 { background-color: green}

remove the dot (.) infront of h1

1 Like

Hello!

If you are attempting to change the color of the text in the h1, the code would not be background-color. It would only require the color property with the green value.

But, as pointed out by Leader stephenmutheu, without knowing more, we are not really certain how to assist.

Hopefully, you have been able to move on now.

It helps if you give the entire code you are working with, and not just part of it. If removing the . in front of the h1 does not fix the issue then are you sure your style tags are right? Is the css in a different file? If so is your link correct?

1 Like

try this:
h1{
background-color: green;
}

1 Like