Alex
Alex

Reputation: 13

Background image in HTML not showing up

I have this code in HTML:

.body { background: url('bg.png'); }

I have the HTML file in the same folder as the image, and the image has exactly the same name. I don't have a separate CSS folder, this code is inside in my HTML file.

I have looked at other people with the same problem and none of the responses work.

Any response will be appreciated, even if it does not work. Thank you for your time!

Upvotes: 0

Views: 43

Answers (2)

Marcos Pérez Gude
Marcos Pérez Gude

Reputation: 22158

The body tag is a tag, not a class. Remove your dot:

 body { background: url('bg.png'); }

Apply to this:

 <body>

Upvotes: 4

zolamk
zolamk

Reputation: 6377

.body refers to an element with a class body, to refer to the body tag just get rid of the dot...unless that was a typo.

Upvotes: 3

Related Questions