HTML frames were a feature that allowed developers to divide a web page into multiple sections, each of which could load a separate HTML document. While frames were widely used in the past, they have now largely been replaced by modern web development techniques, such as CSS layout, which offer more control over page layout and are more compatible with modern browsers. Nonetheless, for the sake of completeness, let's dive into frames.
frames using html |
There are three main parts to using frames in HTML: defining the frameset, defining the frames, and defining the content that will be loaded into each frame.
Defining the Frameset:
The frameset defines the overall layout of the frames. It is defined using the <frameset> tag and specifies the number and layout of frames using the cols or rows attribute. Here is an example of a frameset that divides the page into two vertical frame:
In the above example, the cols attribute is used to specify that the page should be divided into two frames, with the left frame occupying 30% of the page width and the right frame occupying 70% of the page width. The frame tags define the content that will be loaded into each frame, with the src attribute specifying the URL of the HTML document to be loaded, and the name attribute specifying the name of the frame.
Defining the Frames:
The frame tag is used to define each individual frame within the frameset. Each frame tag must have a src attribute, which specifies the URL of the HTML document to be loaded into that frame. The name attribute is used to give the frame a name, which can be used to target the frame from other parts of the HTML document or from JavaScript code.
In the above example, we define two frames named "left" and "right" and specify the URLs of the HTML documents to be loaded into each frame.
Defining the Content:
The content to be loaded into each frame is specified using regular HTML documents, just like any other web page. Each HTML document must have a <head> and <body> section, just like a regular HTML document.
For example, the leftframe.html document might look something like this:
Similarly, the rightframe.html document might look something like this:
With all of these parts in place, the browser will display the frameset, dividing the page into two frames according to the specified layout, and loading the content from the specified HTML documents into each frame.
Comments
Post a Comment