Html frames are useful at dividing the web page or the web browser into multiple sections, they separate sections then load differently.
A-frame displays content independent of its container. Multiple frames form a collection and are known as a frameset. The arrangement can be considered similar to the orientation of rows and columns in a table. The frame tag has been deprecated in HTML5.
Each frame has a frame tag to indicate. The horizontal frame is defined by the row attribute of the frame tag, and the vertical attribute is defined by the column attribute of the frame tag in the HTML document. The same window in one frame might display a static banner, a second navigation menu, etc.
Syntax of Frames
In HTML, there is no end tag for the <frame> tag. When we use frames in a webpage, we use <frameset> tag instead of a <body> tag. Using <frameset> is how we instruct the webpage to divide it into frames The <frame> tag defines which HTML document should open as frame.
The attribute cols take the value in pixels and they help at specifying the number and size of columns in a frameset.
Similarly, as we saw above the attribute rows take the value in pixels and they help at specifying the number and size of rows in a frameset.
However, it should be duly noted that the <frame> tag has deprecated in HTML5 and it is no longer used.
4.5 (2,430 ratings)
Different Type of Frames in HTML
One of the uses of frames has always been to load navigation bars in one frame and then load main pages into a separate frame. A-frame tag defines one single window frame within a <frameset>.
<frame> has browser support in Chrome, Internet Explorer, Mozilla, Safari and Opera Mini.
The different and some commonly used attributes in the frame are attributes such as border, scrolling, src, name, etc.
Types of Frame Tag
The <frameset> Tag Attribute
There are five important attributes of the <frameset> and we discuss it here :
1. Col: The vertical frames are given by the col attribute. The width, however, can be specified in 4 ways:
- Pixels: absolute values can be mentioned in pixels. If we have to create three vertical frames, we can give the value: cols=”100,50,100”.
- Percentage: The percentage of the browser window can be mentioned. If we have to create three vertical frames, we can give the value: cols=”40%,20%,40%”
We can also make use of the wildcard here (*) and let the wildcard take the remaining of the window which remains un-mentioned.
2. Rows: The horizontal frames are given by the row attribute. It specifies the rows in a frameset. If we have to create three horizontal frames we use:
We can also set the height of each row as we had done in the case of columns previously.
3. Border: It specifies the width of border of each frame in pixels.
Eg: border=”4”. If border=”0”, means there is no border.
4. Frameborder: If a three-dimensional border needs to be displayed between frames then we use this attribute. The value which the attribute takes is either 1 or 0 ( Yes or No).
Eg: frameborder=”0” means no border.
5. Framespacing: This attribute specifies the amount of space between frames in a frameset. Any integer value can be given here for this attribute.
Eg: framespacing=”12” means between the frames there should be the spacing of 12 pixels.
The <frame> Tag Attribute
There are 8 attributes that can be listed here in this section.
1. src: We provide the file name to this attribute that is supposed to be loaded into the frame. The value of this attribute can be any URL.
Eg: src= www.facebook.com
2. name: This attribute provides a name to the frame. It defines which frame a document should be loaded into. If you have multiple links in one frame which loads into another frame then we make use of this attribute. Then the second frame needs a name to identify itself as the target of the link.
3. frameborder: This attribute is specified to show if the borders are to be shown or not. The value takes up is 1 or 0 (Yes or No).
4. marginwidth: The attribute is helpful at specifying the width of the space between the left and right of the frame’s border and also the content of the frame. The value is given in pixel.
5. marginheight: The attribute is helpful at specifying the height of the space between the top and the bottom of the frame’s border and also the content of the frame. The value is given in pixel.
6. noresize: This attribute basically prevents the user from making any changes to the already present frames. In the absence of this attribute, any frame can be resized.
7. scrolling: This attribute takes control of the appearance of the scrollbars which are present on the frame. The value either a ‘yes’, ‘no’, or ‘auto’.
Eg: scrolling=” no” means it should not have scroll bars.
8. longdesc: This attribute lets you provide a link to another page containing a long description of the content of the frame.
Frames and Browser Support
Old browsers do not support frames then <noframes> elements should be displayed to the user.
In practice the <body> element should be placed inside <noframes> element because the <frameset> element is supposed to replace the <body> element. If the browser fails to understand <frameset> element then it understand the contents of the <body> element which is contained in <noframes> element.
It is a nice approach to put up a message in such scenarios for the user who use old browsers. Messages like “ Sorry! Your browser does not support frames.” to notify.
Conclusion – Html Frames
Frame technology is not supported by quite a number of browsers these days. Many a time, it is noticed that the contents of the webpage are not displayed properly for smaller devices. Anyway, it is good to have knowledge of what existed so that better models could be developed to be compatible with new technologies.
This is a guide to Html Frames. Here we discuss the Different Types of Frames in HTML and the Types of Frame Tag with Frames and Browser Support. You may also look at the following article to learn more –