Skip to content
How do i put an image as a backround in html
Profile icon
cmglj

how do i put an image as the backround in html?

@Coder100
by any chance can you tell me if you know? or anyone.

You are viewing a single comment. View All
Profile icon
Coder100

So to do this, in your style.css add:

body { background: url(img.png); }

But make sure img.png is an actual image (replace img.png with the image of your choice).

Also, to make sure the image is full-size, read this:

html { background: url(img.png) no-repeat center center fixed; background-size: cover; }

Read more about backgrounds here and here

Profile icon
cmglj

@Coder100
how do I put my own pic? bc I tried changing img.png to a link and it didn't work

Profile icon
Coder100

@cmglj
just a sec

Profile icon
Coder100

oh, that's because those aren't valid images

@cmglj