+ 3

How do I make an image a background in my code?

I was trying to figure out how to put my image in the background of my HTML code. Can anyone help me? Example codes would be nice too. (:

9th Jul 2018, 2:08 AM
Noah Garza
Noah Garza - avatar
8 Answers
+ 1
Yes, you can as Rahul Sahni said: background-image: url("linkoftheimage.com") Or if you need just a color for background: background-color: brown or just use color-picker for the hex codes like #008080
9th Jul 2018, 5:41 AM
Zimzo
Zimzo - avatar
+ 2
Thanks!
9th Jul 2018, 3:05 AM
Noah Garza
Noah Garza - avatar
+ 1
<html> <body background="bgimage.jpg"> <h1>Hello world!</h1> <p><a href="https://www.anywebsite.com">Click me</a> </p> </body> </html>
9th Jul 2018, 2:52 AM
Rahul Sahani
Rahul Sahani - avatar
+ 1
So I just add “background” to the body tag? No need to change the closing tag?
9th Jul 2018, 3:17 AM
Noah Garza
Noah Garza - avatar
+ 1
body{ background-image:url("http://website.com"); }
9th Jul 2018, 3:28 AM
Rahul Sahani
Rahul Sahani - avatar
+ 1
Thanks so much that worked!
9th Jul 2018, 3:29 AM
Noah Garza
Noah Garza - avatar
0
no it is not required...
9th Jul 2018, 3:26 AM
Rahul Sahani
Rahul Sahani - avatar
0
one more question... can you make a background in CSS?
9th Jul 2018, 3:27 AM
Noah Garza
Noah Garza - avatar