Example HTML Frames Code:
To make frames in HTML, you need 3 or more pages. One page is the frameset page, the other pages are for each individual frame. The following code is for a frameset page. Note the code pointing to 2 other pages - one for the left frame, the other for the right frame.The frameset page:
The left frame (frame_example_left.html):
The right frame (frame_example_right.html):
View the result
<html> <head> <title>Frameset page<title> </head> <frameset cols = "25%, *"> <noframes> <body>Your browser doesn't support frames. Therefore, this is the noframe version of the site.</body> </noframes> <frame src ="/html/tutorial/frame_example_left.html" /> <frame src ="/html/tutorial/frame_example_right.html" /> </frameset> </html>
The left frame (frame_example_left.html):
<html> <body style="background-color:green"> <p>This is the left frame (frame_example_left.html).</p> </body> </html>
The right frame (frame_example_right.html):
<html> <body style="background-color:yellow"> <p>This is the right frame (frame_example_right.html).</p> </body> </html>
Frame Templates
The frameset tags contain other tags nested within them. These other tags define the actual frames that appear within the document (the frameset document).
You can use the following template as a basis for your HTML frames code. Simply fill in the blanks or remove uneeded attributes.
Since HTML frames code is made up of several tags, each tag is presented separately here.
1. The <frameset> Tag
For an explanation of all the attributes, see the HTML frameset tag specifications.
<frameset rows="" cols="" class="" id="" title="" style="" onload="" onunload="" > (the individual frames go here - see below) </frameset>
2. The <frame> Tag
This tag defines each frame within the frameset.For an explanation of all the attributes, see the HTML frame tag specifications.
<frame name="" longdesc="" src="" noresize="" scrolling="" frameborder="" marginwidth="" marginheight="" class="" id="" title="" style="" />
3. The <noframes> Tag
This tag defines what to display if the browser doesn't support frames.
For an explanation of all the attributes, see the HTML noframes tag specifications.
<noframes class="" id="" title="" style="" lang="" dir="" onclick="" ondbclick="" onmousedown="" onmouseup="" onmouseover="" onmousemove="" onmouseout="" onkeypress="" onkeydown="" onkeyup="" > (content to display if browser doesn't support frames) </noframes>