Skip to: content, navigation

by Ian Lloyd

src (HTML attribute)

Browser support full matrix
IE7 FF2 Saf3 Op9.2
None None None None
Spec
Depr. Version
No HTML 4.01
src="Source of iframe contents"

Example

The src attribute loads "stock-prices.php" into the iframe:

<iframe src="stock-prices.php" height="200" width="200"
frameborder="1" title="The latest stock prices, including Nikkei,
FTSE100" longdesc="stocks.txt">
</iframe>

Description

The src attribute instructs the browser where on the server to look for the web page that should be presented to the user in the current iframe. This may be a file in the same directory, a file somewhere else on the same server or a file held on another server.

The example shows a file in the same directory as the web page that contains the iframe, but if the file was in a directory that is one level higher than the referencing page, the syntax would be:

<iframe src="../stock-prices.php" height="200" width="200"
frameborder="1" title="The latest stock prices, including Nikkei,
FTSE100" longdesc="stocks.txt">

../ equates to ‘move up one directory in the hierarchy’.

You can also reference a file relative to the web site’s root (anything after the domain name):

 <iframe src="/stock-prices.php" height="200" width="200"
 frameborder="1" title="The latest stock prices, including Nikkei,
 FTSE100" longdesc="stocks.txt">
 

Value

The location of the file, relative to the referencing document, relative to the server root or as a complete URI containing the http:// protocol, the server name and the path to the document on that server.

Compatibility

IE5.5None
6.0None
7.0None
Firefox1.0None
1.5None
2.0None
Safari1.3None
2.0None
3.0None
Opera9.2None

Every browser listed supports this attribute.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters