HTML HTML Tutorial HTML Forms HTML Graphics HTML Media HTML APIs HTML Tags



HTML Tag: frame

The HTML <frame> tag is used to divide a web page into multiple sections or frames. Each frame can contain a separate HTML document, allowing for multiple pages to be displayed within a single web page. This tag is commonly used in older websites, but it is not recommended for modern web development due to its lack of support in newer browsers.

The <frame> tag is used in conjunction with the <frameset> tag, which defines the layout of the frames on the page. The <frameset> tag specifies the number of rows and columns of frames, as well as their sizes and positions. Each <frame> tag is then used to define the content of each individual frame.

Here is an example of a basic <frameset> layout:

  <frameset cols="25%,75%">
    <frame src="menu.html">
    <frame src="content.html">
  </frameset>

In this example, the <frameset> tag specifies two columns, with the left column taking up 25% of the page width and the right column taking up 75%. The <frame> tags then specify the content to be displayed in each column, with the src attribute pointing to the HTML documents to be displayed.

It is important to note that the <frame> tag has several attributes that can be used to customize the appearance and behavior of the frames. Some of the most commonly used attributes include:

  • src: Specifies the URL of the HTML document to be displayed in the frame.
  • name: Specifies a unique name for the frame, which can be used to target the frame with links or scripts.
  • scrolling: Specifies whether or not the frame should have scrollbars.
  • frameborder: Specifies whether or not the frame should have a border.
  • noresize: Specifies whether or not the frame can be resized by the user.

Here is an example of a <frame> tag with some of these attributes:

  <frame src="content.html" name="main" scrolling="auto" frameborder="1" noresize>

In this example, the <frame> tag specifies that the content.html document should be displayed in the frame, with the name "main". The scrolling attribute is set to "auto", which means that scrollbars will appear if the content overflows the frame. The frameborder attribute is set to "1", which means that the frame will have a border. Finally, the noresize attribute is set to prevent the user from resizing the frame.

While the <frame> tag can be useful for creating complex layouts, it is important to note that it is not recommended for modern web development. This is because many newer browsers do not support frames, and those that do often have security restrictions that can cause issues with frame-based layouts. Instead, modern web developers typically use CSS and JavaScript to create more flexible and responsive layouts.

References

Activity