/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: src

[this page | pdf | back links]

The HTML src attribute indicates the URL of a resource. It applies to <audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track> and <video> elements.

 

Valid attribute values (when used with <audio>, <embed>, <iframe>, <img>, <script>, <source>, <track> and <video> elements) include:

 

Value

Description

URL

URL of source

 

Valid attribute values (when used with <input> elements) include:

 

Value

Description

URL

URL of image to use as a submit button (only for type = image)

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<img src="Pictures/Shape1.jpg">

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("IMG");
x.setAttribute("src","Pictures/Shape1.jpg");
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile