The src Attribute — HTML

The <img> tag is used to embed an image in an HTML page. You write the image HTML tag in the code of your web page, and then specify certain necessary attributes, such as the src attribute, so that the image displays correctly.

The src attribute identifies the path to the image to be displayed so that the browser knows exactly where in your websites file structure to find it:

<img src=”image-of-the-sky”>

There are two ways to specify the URL in the src attribute:

Absolute URL — An absolute URL links to external content image hosted on another website. Example

Relative URL — A relative URL contains links to content within the website. Links to an image in your image folder.

It is almost always best to use relative URLs when linking within your site, since they will not break if you change your domain, preserving your sites internal link structure.

<< Previous                  Next >>

You are currently working on a course in HTML, to continue navigate using the links above to the next section, or you can return to the Table of Contents.

Cite This Article

MLA

West, Brandon. "The src Attribute — HTML". Projeda, April 22, 2024, https://www.projeda.com/src-attribute-html-course/. Accessed May 2, 2025.

  • Categories