Framing

To create a frame, use the <FRAMESET> tag , which replaces the <BODY> tag in the document and is used to split the screen into areas. Inside this tag are <FRAME> tags that point to an HTML document that is intended to be loaded into the area (see Figure 1).

Fig. 1

Fig. 1. Example of splitting the browser window into frames

To place the frames, as shown in Fig. 1, the code will be as follows.

Example 1. Creating two frames

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Frameset // EN" "http://www.w3.org/TR/html4/frameset.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Frames </ title>
</ Head>
<Frameset cols = "100, *">
<Frame src = "menu.html" name = "MENU">
<Frame src = "content.html" name = "CONTENT">
</ Frameset>
</ Html>

Note that this example uses a different <! DOCTYPE> than in normal HTML documents, this is due to the use of frames. The specified <! DOCTYPE> applies only to the main page that defines the frame structure.

In this example, the browser window is divided into two columns, the left one occupies 100 pixels, and the right window - the remaining space specified by the asterisk symbol. The width or height of the frames can also be set in percentages, like tables.

The <FRAME> tag specifies the name of the HTML file to be loaded into the specified scope using the src parameter. A file called menu.html will be uploaded to the left window and content.html to the right one . It is desirable for each frame to specify its unique name so that documents can be uploaded to the specified window.

Fig. 2

Fig. 2. Example of splitting the browser window into frames

If you need a more complex frame structure, for example, as shown in Fig. 2, tags <FRAMESET> can be put one into the other (example 2).

Example 2. Creating three frames

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Frameset // EN" "http://www.w3.org/TR/html4/frameset.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Frames </ title>
</ Head>
<Frameset rows = "25%, 75%">
<Frame src = "top.html" name = "TOP" scrolling = "no" noresize>
<Frameset cols = "100, *">
<Frame src = "menu.html" name = "MENU">
<Frame src = "content.html" name = "CONTENT">
</ Frameset>
</ Frameset>
</ Html>

The first <FRAMESET> tag breaks the browser window into two lines 25 and 75% wide. And the next, nested - creates two columns, as in Example 1.

Note that the <BODY> tag is not specified when using frames, since the <FRAMESET> tag executes its tag.

Copyright © www.htmlbook.ru