src (HTML attribute)

Spec
Depr. Version
No HTML 4.01
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

src="Source of iframe contents"

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">
 

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>

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

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Every browser listed supports this attribute.

User-contributed notes

There are no comments yet.

Related Products