how to set an image as a background in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to set an image as a background in html

12th Jun 2016, 5:50 AM
Patil Dipesh Vinod
Patil Dipesh Vinod - avatar
5 Answers
+ 5
background of a website, is styled in the body element. basically this is what your css would look like to have a background image of your site. body { margin: 0; padding: 0; background-image: url(images/your_image.png); background-size: cover; background-position: center; background-attachment: fixed; }
12th Jun 2016, 2:30 PM
Trikyas.com
Trikyas.com - avatar
+ 1
choose the background attribute in css or style in line and provide the img url. for example in line would go; "style ="background:url (../img/pic.jpg);" " but remember to control the size, the position, if it'll repeat or not.
12th Jun 2016, 6:45 AM
Cameron Howell
Cameron Howell - avatar
0
you need css code
12th Jun 2016, 4:10 PM
xNPx3
xNPx3 - avatar
0
try set background-image on body{}
18th Jul 2016, 12:26 AM
Ageung Rayi Pamungkas
Ageung Rayi Pamungkas - avatar
0
Write in the body element <body background="imageurl.imagetype"
31st Aug 2016, 10:50 AM
Ahmad Badghaish
Ahmad Badghaish - avatar