Why can I not change the background color in this HTML/CSS file?
Complete beginner here.
I am doing an exercise on learning the tools of HTML and CSS - in this case, how to change the color of the background from white to gray.
As a starting point I watched some YT tutorials and tried to replicate them, just changing colors.
However, despite basically copying the code I saw online, when I run my code it simply didn't work (background is still white).
Also, when I tried to add some other features (like stylizing an unordered list), it didn't work either.
Not sure if I didn't link the CSS file to the HTML properly or if it's something wrong with the code...
Could someone tell me what I did wrong?
Thx a lot!
Hello! If you want to change the background of an entire webpage, in your CSS you should have:
Your container doesn't actually have any content, but when you add some (and keep the current code), there will be a grey background around it.
Glad I could help,
To target the background of the whole page, you want to target the "root" element of a page, the CSS selector for this is:
So, what you're trying to do is this:
Also, this wasn't working because of the percentages, I never use them, they act unexpected at times.
To make something the size of the entire screen use
vh for width and height respectively.