How to set a background image in HTML?

0

How to set a background image in HTML: When you want to add an image to your web page and want to make it attractive, HTML can help you to do this. If you want to set a background image on your web page you both need HTML and CSS. HTML is a type of code which tells the browser what to show on a web page and this is also known as Hypertext Markup Language. CSS is mainly used to change the appearance and layout of the web page and also known as Cascading Style Sheets.

How to set a background image in HTML

Things you should always keep in mind

  • The background image shouldn’t render in any email, Clint. That means that you have to make sure that you know which email clients can support background image.
  • You should always use the resolution of 920 x 1080px or less because a large picture can cause campaigns to display. Try to compress the image.
  • You should host your image on a public server or you can even use a free service so there is no problem in using an absolute file path that shows directly to the folder location in the code.
  • Always choose that type of image which is of a light color so that the text on the web page is visible.
  • When you are editing with CSS make sure you don’t keep any other background prosperities in your code because this can even override the background image.

Part 1: setting up the file:

Step 1: first you have to create a folder to hold HTML file and background image. On your computer, you have to create and name a folder that you can find it later easily.

  • When you are working with HTML you should name the folder by single word name, short name, etc. But it doesn’t matter what name you want to give to the folder.

Step 2: Now you need to know how to put the background image into the HTML folder.

  • If you are not concerned about ensuring that your website will work well on older devices and with slow internet connections in this case you can use a higher resolution picture as your background. Light color pattern image background will go well web site and you can read and can write anything on the top.
  • You can download free background image if you don’t have an image. If you have downloaded the image you can put that image as your background image on HTML folder.

Step 3: Now you have to create an HTML file. First, you have to open a text editor and after that, you need to create new file. After that, you need to save the file as index.HTML.

  • you can also use whatever text editor. Even all system text editors provided by notepad, Mac OS X, TextEdit, and Windows.
  • You can even download Atom, this is a text editor that works on Windows, Linux operating system and Mac OS X. If you want to use a text editor instead for working with HTML.
  • Before starting with HTML and you are using TextEdit. Click on format menu and then click on make plain text. This setting will take care where the HTML file is loads properly in a web browser.
  • Microsoft Word is not great for writing HTML. Because Microsoft words add invisible characters and format which can break HTML file so that it does not display correctly in a web browser.

Part 2: writing the HTML file:

Step 1: you have to copy and paste the standard HTML code which is same for all. You have to past all of them on index.html file.

<!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

<style>

body {

        background-image: url(” “);

}

</style>

</head>

<body>

</body>

</html>

STEP 2: Now you have to add the background image URL. In the index.html file, you have to find the line background-image:url(“ “) you have to type background image file name then paste between the parentheses. When you give a filename without its URL or file path name the web browser will find for web page folder for the named image. You need to add the full path to that file if the file is in another folder on your file system.

Part 3: Reviewing the HTML file

Step 1: you need to open the HTML file in the web browser. You need to right click on the index.html file and then you have to open it in the web browser of your choice.

  • When your file is opened and if you don’t see the image then make sure that the image file name is spelled correctly in the index.html in the text editor windows.
  • When your browser is opened and if you can see HTML code instead of the background image then your index file is saved as a rich text document. You need to try editing the HTML file in a very different text editor.

Step 2: when you want to make edits to the HTML file. In the text editor window you have to move the cursor between the <body> </body> tags and then type hi world! Reload the browser then see the text on the top of the background image.

Benefits of using a background image in HTML:

The background image can attract the visitors and visitors can spend time in your page. Your background image can surely catch the eye of the visitors and if there is an increase in visitors on your page you can develop the page as much you want. HTML will help you in adding a background image.

Conclusion:

The above steps are very important to follow if you want to work on your website. It’s very important if you can put background image light in color and can attract visitors. This can give your website a real hick. You can even grow the website as you want to in the future. You just have to follow the codes and the format properly to achieve a hike in your life.

To know more about How to set a background image in HTML visit Official website.

Leave A Reply

Your email address will not be published.