How to Add Image in HTML Code?

Images are an important part of a webpage. The first thing that attracts the user to the page is an image. These images act as a mirror for the page. The user gets to know what the page is about through these images.  The HTML users would like to know How to add image in HTML. If you are keen on learning the trick, go through the article to know more about the same.

How to Add Image in HTML

How to Add Image in HTML

HTML is the standard markup language. The language is used for creating web applications and web pages. Web pages are not only about the text. Multimedia features of HTML provide you with a way to add audio clips, images, video clips and other elements. The HTML image tag is used to add images to the page. You can set the size and position of the image using the HTML attributes. These attributes help in setting the image according to the frame and device.

See More: GBWhatsApp Plus

Insert Image in HTML

There are various sites that allow you to use their images free of cost. If you do not have an image, download the image from these sites. You can know How to insert image in HTML by using these steps:

  • First, open the HTML document. The HTML document is written in Notepad and saved with HTML extension.
  • Second, look for a point in the document where you want to insert an image. You can use the <img> tag only inside the body of the HTML. The “img” is an empty tag. Empty tags are the one with no closing tag. You will have to add all the attributes on the image in this tag only.
  • Now, you need to find the URL of the image. If you want to add an image from a site, visit the site and right-click the image. Select the copy image location option to copy the URL of the image. Alternatively, you can view the image and copy the URL from the address bar.
  • Use the src attribute next to img tag inside the bracket. The src attribute tells the browser about the location of the image. For example- <img src=”http://www.abc.com/abc.jpg”>.

Insert Image in HTML

  • You should always add “Alt” attribute to the image. In case, the image fails to load the alt text gets displayed on the page.  For Eg- <img src=”http://www.abc.com/abc.jpg” alt=”abc”>.
  • Use the width and height attributes to add dimensions to the image. For Example: <img src=http://www.flower.com/lily.jpg “width=”500” height=”400”>.
  • You can even set HTML image Center using the Class attribute.
  • If you are using style tag then add the attributes like width and height inside the style tag.
  • On the top-left corner, there is a File menu. Click on the File menu. A drop-down sub menu list will open.
  • Click on the Save option to save the changes in the document.

Also, check: WhatsApp Plus Apk

Add Image in HTML

Want to learn How to add image in HTML? If you want to add more flexibility to the image you add, use <picture> tag. Add different source elements inside the picture element. The attributes of all the elements must be different. The browser uses these elements to choose the image best suitable for the view.

Leave a Reply

Your email address will not be published. Required fields are marked *