VOOZH about

URL: https://www.geeksforgeeks.org/html/html-src-attribute/

⇱ HTML src attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML src attribute

Last Updated : 29 May, 2026

The HTML src attribute specifies the source or location of an external resource to be loaded by an element. It is commonly used to link images, media files, scripts, and embedded content.

  • Defines the URL or path of the resource to be loaded.
  • Used with elements such as <img>, <audio>, <video>, <script>, and <iframe>.
  • Supports both relative and absolute URLs.

Syntax:

<element src="url">

HTML src attribute Supported tags

TagDescription
<audio>Embeds sound content for playback in a webpage.
<embed>Integrates external applications or content.
<iframe>Embeds another HTML document within the current one.
<frame>Deprecated. Divides the browser window.
<img>Embed images for display.
<input>Creates interactive control elements in forms.
<script>Embeds or links to external scripts.
<source>Specifies alternative media resources.
<track>Provides text tracks for multimedia elements.
<video>Embeds video content for playback in a webpage.

Attribute Values

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

TermDescription
Absolute URLPoints to a resource outside the current website/domain.
Relative URLPoints to a resource within the same website/domain.

Example of HTML src attribute

Example 1: In this example we displays GeeksforGeeks heading and an audio player with multiple source files for playback control.

Example 2: In this example image linked via the "src" attribute with an alternative text.

Comment
Article Tags: