JavaScript Tutorial

HTML - Frame Attributes

Warning!: HTML frames are a feature that has been deprecated in HTML5, and it is no longer recommended to use them in modern web development.

Frames allowed web designers to split a web page into multiple sections, each with its own scrollable area and content. The attributes used with frames include:

"cols"

The vertical frames are given by the col attribute. The width, however, can be specified in 2 ways:

Pixels: An absolute value can be mentioned in pixels. If we have to create three vertical frames, we can specify the values as: cols=”100,50,100”.

Percentage: The percentage of the browser window can be mentioned. To create three vertical frames, we can specify the values as: cols=”40%,20%,40%”.

Creating index.html

We can also make use of the wildcard here (*) and let the wildcard take the remaining of the window which remains un-mentioned.

Index.html

For frame1, frame2, and frame3, use the same above example file.

"rows"

The horizontal frames are specified by the "row" attribute. It specifies the rows in a frameset. To create three horizontal frames we use: rows="15%,*,25%"

For frame1, frame2 and frame3, use the same above example file.

"border"

The "border" attribute specifies the width of the border of each frame in pixels. If "border='0'", it means there is no border.

"frameborder"

This attribute specifies whether a three-dimensional border needs to be displayed between frames. The value of this attribute can be either 1 or 0 (yes or no). For example, "frameborder='0'" means no border.

"framespacing"

The "framespacing" attribute specifies the amount of space between frames in a frameset. You can specify any integer value for this attribute. For example, "framespacing='12'" means there should be a spacing of 12 pixels between the frames.

Let’s understand the working of border, frameborder and framespacing with the help of an example.

Index.html

For frame1, frame2 and frame3, use the same above example file.

We can also control the UI of the frame tag using different attributes. Below are the eight attributes for the same:-

"src"

This attribute specifies the file name that is supposed to be loaded into the frame. The value of this attribute can be any URL. For example, "src='www.google.com'".

"name"

This attribute provides a name to the frame and defines which frame a document should be loaded into. If you have multiple links in one frame that loads into another frame, then we use this attribute. Then, the second frame needs a name to identify itself as the target of the link. For example, "name='test.html'".

"frameborder"

This attribute specifies whether the borders are to be shown or not. The value can be 1 or 0 (yes or no). For example, "frameborder='1'".

"marginwidth"

This attribute specifies the width of the space between the left and right of the frame's border and also the content of the frame in pixels. For example, "marginwidth='10'".

"marginheight"

This attribute specifies the height of the space between the top and the bottom of the frame's border and also the content of the frame in pixels. For example, "marginheight='10'".

"noresize"

This attribute prevents the user from making any changes to the already present frames. In the absence of this attribute, any frame can be resized. For example, "noresize='noresize'".

"scrolling"

This attribute takes control of the appearance of the scrollbars that are present on the frame. The values can be "yes", "no", or "auto". For example, "scrolling='no'" means it should not have scrollbars.

"longdesc"

This attribute lets you provide a link to another page containing a long description of the content of the frame. For example, "longdesc='frame.html'".

Supporting Browsers

Element

“Google Chrome

Microsoft

Firefox

Opera

Safari

Marquee

Yes

Yes

Yes

Yes

Yes

Go back to Previous Course