How to add a backgroundimage in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to add a backgroundimage in html

14th Dec 2016, 7:07 AM
Sahil Shaikh
Sahil Shaikh - avatar
2 Answers
+ 2
HTML5 prefers that you use CSS to accomplish this. For instance, you can use the style="" attribute to add an inline style to a tag, or call a style via class or id attributes. In any case, the css property required is: background-image: url("imageURLhere"); Other useful properties include: background-size, background-repeat, background-origin, background-position, and also an all encompassing background property. Example: <body style="background-image: url("samplebg.jpg");">
14th Dec 2016, 7:26 AM
Antek
+ 1
simply do this in your CSS file. element{background-image:URL("address of image.extension"); }
14th Dec 2016, 3:56 PM
victor
victor - avatar