HTML <img> srcAttribute

HTML img 标签参考手册HTML <img> Tag

Examples

The image is marked up as follows:

<img src="smiley.gif.html" alt="Smiley face">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the src attribute.


Definition and Usage

The src attribute of the <img> tag is required. It specifies the URL of the image.

Note:When a web page loads, the browser retrieves the image from a web server and inserts it into the page. Therefore, make sure that the image is in the same location as the associated web page, otherwise visitors may get a broken link icon. If the browser cannot find the image, it will display a broken link icon.


Differences between HTML 4.01 and HTML5

None.


Syntax

<img src="URL.html">

Attribute Values

Value Description
URL The URL of the image.

Possible values:

  • Absolute URL - points to another website (e.g. src="http://www.example.com/image.gif")
  • Relative URL - points to a file within a website (e.g. src="image.gif.html")


HTML img 标签参考手册HTML <img> Tag Other Extensions