The general syntax for creating an HTML file with frames is:
HTML tags |
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Page title </title> </head> <frameset> Frame definitions <noframes> <body> Your Web browser does not support frames! </body> </noframes> </frameset> </html> |
where the <frameset> tag is used to store the definitions of the various frames in the file. Note that DOCTYPE for the frameset definition is a bit different from the one used for regular HTML scripts.
The syntax for creating a row layout is:
The syntax for creating a column layout is:
Row and column sizes can be specified in pixels, in percentages of the total size of the frameset, or by asterisk (*). The asterisk instructs the browser to allocate any unclaimed space in the frameset to the particular row or column.
You can enter the frame definition below and check the result.
To specify a source for a frame, use the <frame> tag with the syntax:
where URL is the filename and location of the page that you want to load. This tag must be inserted between the opening and closing <frameset> tags.
The frame tags can be nested. Check what frame layout is produced by the following script (DOCTYPE and some other tags are omitted for simplicity).
HTML tags | Action |
---|---|
<html> <head> <title> Page title </title> </head> <frameset rows="20,*"> <frame /> <frameset cols="*,*"> <frame /> <frame /> </frameset> </frameset> </html> |