How to set src to the img tag in HTML from another domain?


To use an image on a webpage, use the <img> tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load. With HTML, add the image source as another domain URL. For that, add the src attribute as a link to another domain.

The following are the attributes:

Sr.No.
Attribute & Description
1
alt

The alternate text for the image
2
height

The height of the image
3
ismap

The image as a server-side image-map
4
longdesc

The URL to a detailed description of an image
5
src

The URL of an image
6
usemap

The image as a client-side image-map
7
width

The width of the image

Just keep in mind the <img> tag has no end tag.

Example

You can try to run the following code to set src to the img tag in HTML from another domain

Live Demo

<!DOCTYPE html>
<html>
   <head></head>
   <body>
      <h2>Qries</h2>
      <img src="https://www.qries.com/images/banner_logo.png" alt="Qries" width="200" height="90">
   </body>
</html>

Updated on: 09-Jan-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements