Src Attribute

  • Source Location: The src attribute specifies the source (URL) of the image.
  • Required Attribute: It is a mandatory attribute for the <img> tag.
  • URL or Path: The value can be a URL pointing to an external image or a relative or absolute path to an image file.
  • Embedding: It can also represent embedded images by providing the data URL.
  • Fallback: If the image fails to load, the text specified in the ‘alt’ attribute is displayed instead.

What is the role of the src Attribute in Tag ?

The src attribute in the <img> tag specifies the source URL or file path of the image to be displayed on the webpage. The browser needs to fetch and render the image correctly. Without a valid “src” attribute, the image would be missing or broken on the web page.

Similar Reads

Syntax

alternative-text...

Attribute Values

It contains a single-value URL that specifies the link to the source image. There are two types of URL links which are listed below:...

Src Attribute

Source Location: The src attribute specifies the source (URL) of the image. Required Attribute: It is a mandatory attribute for the tag. URL or Path: The value can be a URL pointing to an external image or a relative or absolute path to an image file. Embedding: It can also represent embedded images by providing the data URL. Fallback: If the image fails to load, the text specified in the ‘alt’ attribute is displayed instead....