THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML <img> src Attribute

HTML img Tag Reference HTML <img> tag

Example

An image is marked up as follows:

<img src="smiley.gif" alt="Smiley face">
Try it yourself »

Definition and Usage

The required src attribute specifies the URL of the image.

Note: When a web page loads; it is the browser, at that moment, that gets the image from a web server and inserts it into the page. Therefore, make sure that the image actually stay in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon is shown if the browser cannot find the image.


Browser Support

Attribute
src Yes Yes Yes Yes Yes

Differences Between HTML 4.01 and HTML5

NONE.


Syntax

<img src="URL">

Attribute Values

Value Description
URL The URL of the image.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/image.gif")
  • A relative URL - points to a file within a web site (like src="image.gif")

HTML img Tag Reference HTML <img> tag