Open In App

How to create frames ?

The task is to create frames using HTML. HTML is  HyperText Markup Language, and it is the standard markup language for creating web pages. It describes the shape of a web page and includes a sequence of elements.

Frames in HTML are used to divide your browser window into more than one section in which every phase can load a separate HTML report and a group of frames within the browser window is referred to as a frameset.



It is never recommended to use frames on your web page because of the following reasons.

Let us see how we can create a frame using HTML.



Instead of using the <body> tag, you can use the <frameset> tag for using a frame. The <frameset> tag is used to define how to divide the window into frames. The horizontal frames are defined by the row attribute and the vertical frames are defined by the col attribute.

Approach:




<!DOCTYPE html>
<html>
    <body>     
        <h3>frame 1</h3>
        <p> This content is in frame 1 </p>
    </body>
</html>




<!DOCTYPE html>
<html>
    <body>     
        <h3>frame 2</h3>
        <p> This content is in frame 2 </p>
    </body>
</html>




<!DOCTYPE html>
<html>
    <body>     
        <h3>frame 3</h3>
        <p> This content is in frame 3</p>
    </body>
</html>

Example 1: The following example demonstrates the HTML <frameset> with cols attribute. The following code uses all of the above files i.e “frame1.html”, “frame2.html” and “frame3.html” as frames.




<!DOCTYPE html> 
<html>
  
<body>
  <frameset cols="*,*,*">
    <frame src="frame1.html"
    <frame src="frame2.html">
    <frame src="frame3.html">
  </frameset
</body>
  
</html>

Output:    

column frames

Example 2: In the following example, just change the cols to rows in the <frameset> tag. The codes for “frame1.html”,”frame2.html”,”frame3.html” are given before the examples.




<!DOCTYPE html> 
<html>
  
<body>
  <frameset rows="*,*,*">
    <frame src="frame1.html"
    <frame src="frame2.html">
    <frame src="frame3.html">
  </frameset
</body>
  
</html>

Output:

row frameset


Article Tags :