-3

I have a class named body. I'm adding some CSS to it. I already had a property called background color and I'm trying to add another property, once I added it both properties it wasn't working and I want to know why?

5 Answers5

1

You need to give more details about the problem you are having. Also note that with css property and value declaration should end with a semicolon.

.body {
  background-color: blue;
  color: red;
}
samuel Ndu
  • 26
  • 1
0

Check if the properties you adding use proper syntax (semi-colons especially). It's likely you forgot to add a semi colon at the end of your first CSS property.

Also check if you are adding the property to the right class.. giving it a unique name will help.

Kermit
  • 4,922
  • 4
  • 42
  • 74
Shadow
  • 1
  • 1
0

You don't need to declare body as class again unless you add something to it, body is global class and not really need to be re-declare again.

Eshjay
  • 1
  • 1
0

You should have stated your question by adding the code here to know where your error is, but you can note this:

  1. make sure in your CSS, your prperty starts with point, i.e the full stop symbol, so it should be .body

  2. inside your parenthesis, that is the curly brackets, write your property, followed by a colon and the its attribute followed by a semi-colon, the you proceed with another property. sample

HTML <div class="body">This is the class named body</div>

CSS

.body {background: blue; color: red;}
Phenom
  • 19
  • 1
0

You might also check your style sheet link to HTML, I mean to if you correctly link main. Css file to your html Index.