- Html frame no margin
- Attributes
- Example
- A frameset document
- Specifications
- Browser compatibility
- See also
- Found a content problem with this page?
- MDN
- Support
- Our communities
- Developers
- HTML Frames
- Creating Frames
- Two Column Frameset
- Add a Top Frame
- Remove the Borders
- Load Another Frame
- Tag Reference
- The frameset Tag
- The frame Tag
- The noframe Tag
- Related
- Color, Margin and Control
- Background Color
- Frame Border Color
- Setting Margins
- Setting User Controls
Html frame no margin
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The HTML element defines a particular area in which another HTML document can be displayed. A frame should be used within a .
Using the element is not encouraged because of certain disadvantages such as performance problems and lack of accessibility for users with screen readers. Instead of the element, may be preferred.
Attributes
Like all other HTML elements, this element supports the global attributes.
This attribute specifies the document that will be displayed by the frame.
This attribute is used for labeling frames. Without labeling, every link will open in the frame that it’s in – the closest parent frame. See the target attribute for more information.
This attribute prevents resizing of frames by users.
This attribute defines the existence of a scrollbar. If this attribute is not used, the browser adds a scrollbar when necessary. There are two choices: «yes» for forcing a scrollbar even when it is not necessary and «no» for forcing no scrollbar even when it is necessary.
This attribute defines the height of the margin between frames.
This attribute defines the width of the margin between frames.
This attribute allows you to specify a frame’s border.
Example
A frameset document
doctype html> html lang="en-US"> head> head> frameset cols="400, 500"> frame src="https://developer.mozilla.org/en/HTML/Element/iframe" /> frame src="https://developer.mozilla.org/en/HTML/Element/frame" /> frameset> html>
If you want to embed another HTML page into the of a document, use an element.
Specifications
Browser compatibility
BCD tables only load in the browser
See also
Found a content problem with this page?
This page was last modified on Jul 7, 2023 by MDN contributors.
Your blueprint for a better internet.
MDN
Support
Our communities
Developers
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.
HTML Frames
In HTML, frames enable you present multiple HTML documents within the same window. For example, you can have a left frame for navigation and a right frame for the main content.
Frames are achieved by creating a page, and defining each frame from within that page. This frameset page doesn’t actually contain any content — just a reference to each frame. The HTML tag is used to specify each frame within the frameset. All frame tags are nested with a tag.
So, in other words, if you want to create a web page with 2 frames, you would need to create 3 files — 1 file for each frame, and 1 file to specify how they fit together.
HTML frames are no longer recommended by the HTML specification (as of HTML5) due to their poor usability. It is recommended that you use the element to create iframes instead.
Alternatvely, you can use CSS to create HTML5 compliant frames.
Creating Frames
Two Column Frameset
The frameset (frame_example_frameset_1.html):
The left frame (frame_example_left.html):
The right frame (frame_example_right.html):
Add a Top Frame
You can do this by «nesting» a frame within another frame.
The frameset (frame_example_frameset_2.html):
The top frame (frame_example_top.html):
(The left and right frames don’t change)
Remove the Borders
You can get rid of the borders if you like. Officially, you do this using frameborder=»0″ . I say, officially because this is what the HTML specification specifies. Having said that, different browsers support different attributes, so for maximum browser support, use the frameborder , border , and framespacing attributes.
The frameset (frame_example_frameset_3.html):
(The left, right, and top frames don’t change)
Load Another Frame
Most websites using frames are configured so that clicking a link in one frame loads another frame. A common example of this is having a menu in one frame, and the main body in the other (like our example).
This is achieved using the name attribute. You assign a name to the target frame, then in your links, you specify the name of the target frame using the target attribute.
Tip: You could use base target=»content» at the top of your menu file (assuming all links share the same target frame). This would remove the need to specify a target frame in each individual link.
The frameset (frame_example_frameset_4.html):
The left frame (frame_example_left_2.html):
The yellow frame (frame_example_yellow.html):
The lime frame (frame_example_lime.html):
Tag Reference
Here’s some more info on the above tags.
The frameset Tag
In your frameset tag, you specify either cols or rows , depending on whether you want frames to go vertically or horizontally.
Attribute | Description |
---|---|
rows | Specifies the number of rows and their height in either pixels, percentages, or relative lengths. Default is 100% |
cols | Specifies the number of columns and their width in either pixels, percentages, or relative lengths. Default is 100% |
The frame Tag
For each frame you want to display, you specify a frame tag. You nest these within the frameset tag.
The noframe Tag
The noframes tag is used if the user’s browser doesn’t support frames. Anything you type in between the noframes tags is displayed in their browser.
If you’re interested in building a frames based website, these HTML frames templates will help get you started.
Related
Color, Margin and Control
Alright then, so far we’ve learned how to make basic and advanced frame layouts, how to make hyperlinks in frames and how to adjust the border widths in frames. Now let’s round out our frame rendering skills by learning how to add some color and how to tweak some of the user controls.
We’ll start with color. (All the examples below will be a modification of the advanced frame layout discussed in more detail on a previous page.)
Background Color
Rendering the background color of each frame in your frame layout is a no-brainer. To do this, you have only to adjust the background color of the frame source document loaded into the frame. For more information, see Page Color and Background.
Here’s our advanced frame layout using a background color for the header and site menu frames.
Here’s the same except with no borders. As you can see, this is already a vast improvement on the default appearance of the advanced frame layout.
Frame Border Color
You can adjust the color of the borders in your frame layout by using the bordercolor attribute in either the or start tags. When used in the tag, bordercolor affects the borders of all frames in that particular frameset. When used in the tag, bordercolor affects only the borders in that particular frame. The value can be any valid color expression.
Let’s take the previous example and modify the source code so that it will display a 10 pixel black border in the top frame only:
- Since the frameborder attribute is omitted in the primarytag then the default is frameborder=»yes» (all frame borders are rendered). The framespacing=»10″ attribute/value pair renders a 10 pixel border in Internet Explorer and Opera while the border=»10″ attribute/value pair renders a 10 pixel border in Gecko-based browsers .
- The bordercolor=»black» in the first tag renders the top frame row border black in Internet Explorer and Gecko-based browsers ( bordercolor is not supported in Opera).
- The frameborder=»no» attribute/value pair in the nestedtag turns off all frame borders in the bottom frame row (which is split into two columns).
Setting Margins
You can set the margins in each frame by using the marginwidth and marginheight attributes in your tags. The marginwidth attribute will set the amount of white space to be displayed on the left and right side of your frame’s contents while the marginheight attribute sets the amount of white space to be displayed on the top and bottom. The value is a number specifying the width or height in pixels.
We’ll build upon our previous example by setting all margins of the content frame. The top and bottom margins will be set to 30 pixels while the left and right margins will be set to 50 pixels.
Setting User Controls
- noresize ~ The default setting in HTML frames permits the user to resize any frame by hovering the mouse pointer over the frame border and then clicking-and-dragging. Inserting the noresize attribute in any tag will disable resizing in that frame.
- scrolling Red»>yes|no|auto| « ~ Frames automatically display horizontal or vertical scrollbars whenever the frame’s content outsizes the allotted dimensions of that particular frame. If the frame’s content fits within the allotted dimensions, however, then no scrollbars are displayed. This is the default setting for frames and is the same as using the scrolling=»auto» attribute/value pair. If you wish to always display scrollbars in a particular frame then use scrolling=»yes» . If you wish to always hide scrollbars in a particular frame then use scrolling=»no» .
By now you have enough information to create a full-blown framed website but before you launch it, you should be well aware of some of the common problems when using frames.
If you need a .COM web address, you can get one quick and easy at.