Advertisement
hjysy

How to Insert a Background Image in HTML

Mar 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. How to Insert a Background Image in HTML
  2.  
  3.  
  4. HTML is a useful tool to use if you want to add images to your web page. However, if you want to insert a background image in HTML, you need both HTML and CSS. In this article, know how to insert a background image in HTML.
  5.  
  6. ++++++++++++++
  7. If You want to buy cheap web hosting then visit http://listtop.pw and select the cheapest hosting. it can be suitable for all your needs.
  8.  
  9. Top 200 best traffic exchange sites http://listtop.pw/surf
  10.  
  11. Listtop.pw
  12. Listtop.pw
  13. Listtop.pw
  14.  
  15. +++++++++++++++
  16.  
  17. HTML AND CSS
  18.  
  19. HTML means Hypertext Markup Language. It is a code that commands the browser on which elements should be shown on a web page.
  20.  
  21. CSS, on the other hand, means Cascading Style Sheets, and it is used to make changes to the layout and appearance of a web page.
  22.  
  23. In order to insert a background image in HTML, you need a good background image to use for your page.
  24.  
  25. SETTING UP THE FILES
  26.  
  27. On your PC, create a folder with a name and make sure it’s easy to find later.
  28. Put the background image inside the folder.
  29. Create an HTML file. To do this, simply open a text editor and create a new file. Name the file “index.html”.
  30. WRITING THE HTML FILE
  31.  
  32. Copy the HTML code below:
  33. <!DOCTYPE html>
  34. <html>
  35. <head>
  36. <title>Page Title</title>
  37.  
  38. <style>
  39. body {
  40. background-image: url(” “);
  41. }
  42.  
  43. </style>
  44.  
  45. </head>
  46.  
  47. <body>
  48.  
  49. </body>
  50. </html>
  51.  
  52. 2. Paste the code into the index.html file.
  53.  
  54. 3. In the HTML file, find the line “background-image: url(” “);”. Then, type the image’s file name. Include the image’s file extension. After, save the HTML file.
  55.  
  56. REVIEWING THE HTML FILE
  57.  
  58. Open the file in the web browser. To do this, simply right-click on the file and then select “Open with”. You can select any web browser of your preference.
  59. In the text editor, insert “Hello World!” between the two <body> tags.
  60. Reload the browser to see the text inserted on top of the background image.
  61. UNDERSTANDING THE HTML CODE
  62.  
  63. Understand the HTML code. The HTML code comes with open and closed tags.
  64. Every HTML page should start with <!DOCTYPE html>.
  65. The <title> tag appears on the title bar of the browser. It also appears on the browser tab.
  66. The <style> tag includes the CSS content.
  67. The <body> tag includes written texts.
  68. UNDERSTANDING THE CSS CODE
  69.  
  70. The CSS code that comes between the <style tag> commands the browser to add a background image to the body with a specific name.
  71.  
  72. Follow this guideline to successfully add a background image. With the right knowledge, it’s easy to learn how to insert a background image in HTML.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement