CSS body not working-what am I doing wrong?

I’m just trying to use the body tag in CSS to customize the text etc. Ive been trying for over an hour to solve this simple problem and I’m just stuck.

Looks like it may be nested in the background class.

1 Like

Thanks you were right! However, after fixing that it still doesn’t work. :frowning:

Bummer. One approach that works for me in this sitch- I copy my css to a text document so I don’t lose it - and just leave the body element styling in the css file - all on its own. If it still doesn’t work, then I know there’s something wrong with how I’ve formatted it. Otherwise, you’re down to something else in your CSS that’s overwriting it.

1 Like

First of all Whenever you give a size to any text, you should always mention the units such as px or em.

You shouldn’t use body selector for universal color or font size. There is another CSS selector for this.
Just change your body selector from

body {


* {

This is called universal selector. You can set the margins and paddings of all HTML elements at once with this. However if you want to change the color of any text, you should use h1, or p selector for that purpose.

1 Like

When working with Codepen, the HTML-Field is already the inside of the <body></body>.
Your bootstrap-stylesheet should be implemented via the cogwheel in the section “Add External CSS”. The same goes for your external Javascript Stuff.

The Problem here is, that your Bootstrap-CSS overwrites your Codepen-CSS because you created the connection inside the HTML-Field.

By the way:
I saw that you opened the <div class="container-fluid"> before your <body> tag. Same with your footer-stuff, you closed your body and then created the footer. Everything which is displayed on your Page should go in-between the <body></body> tags.

Hope this helps.
And of course remember the units after your font-size, just like @naeemrind noted!


I saw that your div tag is outside of your body tag
The footer is also outside of the body.

Try putting the tags back in order and try again.

     <!-- more content here -->

Oh thank you! I didn’t know that. I appreciate you taking the time to help.

Wow, thank you thank you thank you! This is so helpful! If you hadn’t told me that’s I would have kept trying and failing for eternity. I didn’t even begin to think that I put that in the wrong place. I appreciate you taking the time to help me with that!

Thank you so much! This is the solution I have been looking for!

I guess those kind of errors occur a lot and it’s important to learn how to detect and avoid them. That’s why I recommend to learn from the web. If it gets too hard for you, you can always try using some helps as help, such as checkamrx or others.
Good luck learning.