How to add background image on article | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

How to add background image on article

I want to use an image as a background to the body of my html page

8th Jan 2017, 3:34 PM
Manish K. Baranwal
Manish K. Baranwal - avatar
10 Answers
+ 19
HTML way: <body background="image.jpg"> CSS way: body {     background-image:url("image.jpg"); } js way: <script type="text/javascript"> $(document).ready( function() { $('body').css('background-image', image.jpg)'); }); </script>
8th Jan 2017, 3:41 PM
Caffeinated Gamer YT
Caffeinated Gamer YT - avatar
+ 5
CSS: body { background: url(http://example.com/background.png) no-repeat center center fixed; } background.png is the image file for the background
8th Jan 2017, 3:38 PM
Skayo
Skayo - avatar
+ 3
how about just adding href attribute in there
9th Jan 2017, 2:38 PM
Zinedine Riza
Zinedine Riza - avatar
+ 3
<style> .art{ background-image: url("frog.jpg"); } </style> </head> <body> <div class="art"></div>
9th Jan 2017, 7:33 PM
ARNAB BISWAS
ARNAB BISWAS - avatar
+ 2
Body { Background-image: url(); Background-size: 0px; }
9th Jan 2017, 5:27 PM
user01220828010
+ 1
Edited. But you should download the image and upload it to your server. Provides faster loading.
8th Jan 2017, 3:58 PM
Skayo
Skayo - avatar
+ 1
in most cases article is inside a section but let's suppose you have only one article in your html file,though, open up your css file and type this in: article { background-image: url (../image/image.png/) no-repeat (center,left,right ) for x and (top,center,bottom) for you }//remind yourself about the image sizes which can also be controlled by background-size in case of using sign graphics. other than this go to csstricks.com
9th Jan 2017, 4:01 PM
Rafael
Rafael - avatar
0
not working. trying to use an image from online link
8th Jan 2017, 3:55 PM
Manish K. Baranwal
Manish K. Baranwal - avatar
0
I m with Manish
9th Jan 2017, 3:48 PM
nikita
nikita - avatar
0
Background can be included in html by various ways- 1. By html <body background="image.jpg"> </body> 2. By css a) Using external css CSS: .body { background-image: url (image.jpg); } /* save css file In my case, i saved it as test.css */ HTML: <head> <link rel="stylesheet" type="text/css" href=test.css"> b) Using internal css <style> #body { background-image: url (image.jpg); } </style> c) Using in-line css <body style="background-image: url (image.jpg)">
10th Jan 2017, 6:24 AM
Rajat Samuel
Rajat Samuel - avatar