Taha Karaca
Taha Karaca

Reputation: 129

CSS code not working if I put "." in front of any element

I am using 4.5.1 Framewok and VS 2013. My problem is my CSS code doesn't work if I write the following:

.body {
  font-family: Verdana, Arial, sans-serif;
  font-size: 14px;
  background: gainsboro;
}

But if I write like this it is working:

body {
  font-family: Verdana, Arial, sans-serif;
  font-size: 14px;
  background: gainsboro;
}

What can be the reason of this? I watched some people videos in which they are using ".body", their projects are working, but if I write this too it doesn't work. Can you help me?

Upvotes: 5

Views: 100

Answers (2)

Victor Luna
Victor Luna

Reputation: 1814

if in your html you are using body as a tag, then in your css you have to use "body {content.... }". However, if you are using body as a class "div class="body" then you can style the div using .body.

Upvotes: 2

GuilhE
GuilhE

Reputation: 11871

"."NAME will affect all tags with class="NAME"
"#"NAME will affect the tag with id="NAME"
"NAME" will affect all html elements of the type NAME

If you want to apply the style to the BODY you have to remove the ".", If you have tags with the class="body" you then use ".body".

Upvotes: 3

Related Questions