MCCC CIS 177 - Markup Languages

5.0 Create Framesets

5.02 Introduction to Frames

The <frameset> and <frame> tags allows you to divide a window into multiple sections, with each section displaying a different HTML page. Because many designers have used framesets indiscriminately, frames have become the subject of great debate among Web surfers. In addition, when you provide links to other people's pages and force those pages into your frames, you degrade and possibly destroy the design structure intended by the page's author. Doing so is considered rude and poor design practice. The decision to use frames depends on your site design strategy including your target audience, navigational structure and other design decisions. Frameset tags replace the body tag. For backward compatibility and to display a message to users whose browser does not support frames, include <noframes>Insert substitute text here to inform the user their browser does not support frames</noframes>.

5.05 Plan Frame Layout

Before writing frameset code, it's necessary to plan what pages you want to initially appear in each frame when the frameset is loaded and how each of the frames will change based on your navigation structure. Specifically, you need to decide the folowing:

  • What content will initially appear in each frame?
  • How many frames do you need?
  • How should the frames be positioned on the screen and what size should they be?
  • Which frames will remain static and which ones will change, and how do they change?
  • Should you allow users to resize frames and should the frames scroll if necessary?

5.06 Create Frame Layout

The basic syntax for creating a frameset is:

<html>
<head>
<title>Page Title</title>
</head>

<frameset>

Frame definitions

</frameset>

<noframes>No frames content here</noframes>

</html>

 

Create Frames in Rows and Columns

Frames in rows

Click here to view a sample frameset

Syntax:

<frameset rows="100,*">

    <frame name="menu" src="menu.html">
    <frame name="body" src="body.html">

<noframes>Substitute content goes here</noframes>

</frameset>

Create frames in rows

  1. Download the lesson files.
  2. Create a new HTML document.
  3. Create a frameset with two rows with the one on the top 100 pixels high and the one on the bottom taking up the rest if the window. Name the top frame navbar which displays navbar.html and the bottom frame main which displays main.html.
  4. Insert <noframes> tag.
  5. Save the file as lab05a.html.
  6. View the file in the browser.

Frames in columns

Click here to view the frameset

 

<frameset cols="150,*">
    <frame name="menu" src="menu.html">
    <frame name="body" src="body.html">

</frameset>

<noframes>Substitute content goes here</noframes>

Create frames in columns

  1. Edit the lab05a.html document.
  2. Change the frameset to two columns with the one on the left 150 pixels wide and the one on the right taking up the rest if the window. Name the left frame navbar1 which displays navbar1.html and the right frame main which displays main.html.
  3. Save the file as lab05b.html.
  4. View the file in the browser.

 

Frames in rows and columns

Click here to view the frameset

 

<frameset rows="*,*" cols="*,*" >
    <frame name="topLeft" src="frame1.html" >
    <frame name="topRight" src="frame2.html" >
    <frame name="bottomLeft" src="frame3.html" >
    <frame name="bottomRight" src="frame4.html">

</frameset>

<noframes>Substitute content goes here</noframes>

Create frames in rows and columns

  1. Edit the lab05b.html document.
  2. Change the frameset to two rows 15%, *; and two cols 150, *. Name the top left frame topleft which displays blank.html. Name the top right frame topright which displays heading.html. Keep the navbar1 and main frames the same as before.
  3. Save the file as lab05c.html.
  4. Create the two additional documents (blank.html and heading.html) that appear in in the top row.
  5. View the file in the browser.
5.13 Contol Frame Appearance

Borders & Frameborders

By default, the browser will display 5 pixel scultped frame borders. The border attribute lets you control the space between frames, while the frameborder attribute lets you optionally fill the space with sculpted borders. You can choose turn borders off by setting the border attribute to 0. You can optionally specify border colors using the bordercolor attribute. All three attributes are used in the frameset tag. To ensure the the frameset has no borders, use both border and frameborder attributes.

Click here to view frameset - no borders

<frameset rows="*,*" cols="*,*" border="0" frameborder="0">

Click here to view frameset - sculpted color borders

<frameset rows="*,*" cols="*,*" border="25" frameborder="1" bordercolor="black">

Scrollbars

By default, the browser will cause both horizontal and vertical scrollbars to appear if the contents of the frame exceeds the available screen space. You can disable this with the scrolling attribute in each frame tag. Possible values are no, yes, auto.

<frame name="framename" src="page.html" scrolling="no">

Margins

The browser also automatically creates an 8 pixel margin on each side of a frame. To eliminate the margins, use the marginwidth and marginheight attributes in each frame you want to control.

<frame name="framename" src="page.html" marginwidth="0" marginheight="0">

Resizing

When you specify a frame height or width using percentage or the * variable, the browser automatically resizes the frames as needed if the window is resized. By default, users can also manually resize frames using their mouse. To prevent users from resizing, use the noresize attribute in each frame you want to control.

<frame name="framename" src="page.html" noresize>

Customize a Frameset

  1. Edit lab05c you previously made.
  2. Add a 25 pixel lime border and set frameborder to 1.
  3. Add a 15 pixel margin on all sides for each frame.
  4. Prevent scrolling and resizing in the top row and left column.
  5. Save the file as lab05d.html and view in the browser.