Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

src attribute | src property

Sets or retrieves a URL to be loaded by the object.


HTML<element src="p" ... >

p = object.src


Property values

Type: String

The URL.


The value of the src attribute of the img and input type=image elements depends on the context of the reference to the attribute. When read as a Document Object Model (DOM) attribute, src returns a URL relative to the hosting domain. The value specified by the page author is returned when src is read as a content attribute, when the page is displayed in an earlier document compatibility mode.


This example uses the src property to change the image's src attribute.

<body onmousedown="oImage.src='sphere.png'" onmouseup="oImage.src='cone.png'">
	<img id="oImage" src="cone.jpeg">


See also

input type=image



© 2015 Microsoft