HTML src Attribute
Example
<img src="demo/image.jpg" alt="demo" width="300" height="200">
Meaning
The src attribute specifies the URL for resources.
Standard Syntax
<element src="URL">
Browser Support
Status
Applies to:
The src attribute can be used on the following element:
Element | Attribute |
---|---|
<audio> | src |
<embed> | src |
<iframe> | src |
<img> | src |
<input> | src |
<script> | src |
<source> | src |
<track> | src |
<video> | src |
Attribute Values
Value | Description |
---|---|
URL | Value can be
|
More Examples
<audio> Tag Example
<audio src="audio/demo.mp3" controls>
Your browser does not support the audio tag.
</audio>
<embed> Tag Example
<h1>embed video</h1>
<embed type="video/webm" src="demo/video.mp4" width="300" height="150"><br><br>
<h1>embed image</h1>
<embed type="image/jpeg" src="demo/image.jpg" width="300" height="150">
<iframe> Tag Example
<iframe src="demo/demo.html">
Your browser does not support iframe element.
</iframe>
<input> Tag Example
<form action="action.php">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<input type="image" src="demo/submit.jpg" alt="Submit" width="50" height="50">
</form>
<script> Tag Example
<script src="demo/demo.js"></script>
<source> Tag Example
<audio controls>
<source src="demo/demo.mp3" type="audio/mpeg">
<source src="demo/demo.ogg" type="audio/ogg">
Your browser does not support the audio tag.
</audio>
<track> Tag Example
<video width="340" height="260" controls playsinline>
<source src="demo/video.mp4" type="video/mp4">
<source src="demo/video.webm" type="video/webm">
<track src="demo/ensubtitle.vtt" kind="subtitles" srclang="en" label="English">
<track src="demo/frsubtitle.vtt" kind="subtitles" srclang="fr" label="French">
Your browser does not support the video tag.
</video>
<video> Tag Example
<video src="demo/video.mp4" width="340" height="260" controls>
Your browser does not support the video tag.
</video>