logo

🧱 Frames in HTML – Detailed Explanation (CBSE Class 10)


🌐 1. What are Frames?

Frames in HTML are used to divide a web page into multiple sections.
Each of these sections can display a different HTML document.
This lets users view more than one web page in a single browser window.

Key Points & Elaboration

  • Divide Webpage: Frames split a browser window into two or more parts.

    • Each part acts like a mini-browser.
    • Every frame can load a separate webpage.
  • Multiple Pages Together:
    Users can see side-by-side pages without switching tabs.

Examples

  1. A frame on the left shows the website menu; the right frame displays page content.
  2. One frame holds a logo at the top, and another shows the changing content below.
  3. Frames are like picture frames on a wall, each holding a different picture (webpage).

🖼️ 2. Why Use Frames?

Frames help design complex web layouts easily.
They are useful for:

  • Displaying multiple documents at once (for comparison or multi-panel views).
  • Keeping navigation menus or headers visible at all times, even when users scroll or change the main content.
  • Organizing large websites into different sections (for easy maintenance and navigation).

Examples

  1. News websites can keep categories in one frame, while stories open in another.
  2. Online learning portals may use one frame for chapters (menu) and another for lessons.
  3. In a library website, you can explore genres in one frame and display book details in another.

🧩 3. Tags Used for Frames

There are two main tags for frames:

  • <frameset>: This tag defines how the window is split (into rows/columns).
  • <frame>: This tag tells what each section should display (which HTML file).

Important:
When using <frameset>, you do not use the <body> tag.
<frameset> replaces <body> when frames are present.

Examples

  1. <frameset rows="50%, 50%"> splits the window into two horizontal frames.
  2. <frameset cols="30%, 70%"> splits the window vertically.
  3. Nested **<frameset>**s are used for complex structures.

🧱 4. The <frameset> Tag

The <frameset> tag defines how your browser window or screen is divided:

  • Rows divide the window horizontally (top and bottom).
  • Columns divide the window vertically (side by side).

Syntax

<frameset cols="50%,50%">
  <frame src="left.html">
  <frame src="right.html">
</frameset>
  • This creates two vertical sections, each taking half the window.

Explanation:

  • cols="50%,50%" creates two columns.
  • rows="30%,70%" would create two horizontal sections (top 30%, bottom 70%).

Examples

  1. <frameset cols="70%,30%"> for a big main area and a slim side bar.
  2. <frameset rows="20%,80%"> for a small header and a larger main body.
  3. <frameset cols="33%,34%,33%"> splits into three equal vertical parts.

Attributes of <frameset>

AttributeDescriptionExample
colsHow many vertical sections (and widths)cols="40%,60%"
rowsHow many horizontal sections (and heights)rows="25%,75%"
borderWidth of divider lines between framesborder="2"
bordercolorColor of those border linesbordercolor="red"
frameborderShow (1) or hide (0) the bordersframeborder="0"

Examples

  1. cols="50%,50%" for two equal columns.
  2. rows="40%,60%" border="3" for two rows with a thick divider.
  3. bordercolor="green" to make lines green.

Activity: Creating a Simple Frame Page

Step by Step Instructions

  1. Open Notepad or any text editor.
  2. Type
    <html>
      <frameset cols="50%,50%">
        <frame src="menu.html">
        <frame src="main.html">
      </frameset>
    </html>
    
  3. Save as frameset.html.
  4. Make two more files: menu.html and main.html (just add simple texts to each).
  5. Open frameset.html in your browser.

Observation:
You see your browser divided into two vertical halves. Each half shows contents of menu.html and main.html.


🪟 5. The <frame> Tag

A <frame> is placed inside <frameset>.
It specifies which HTML file to display in that section.

Key Attributes

AttributeDescriptionExample
srcThe HTML page to load in the framesrc="menu.html"
nameName to refer to this frame (for link targets)name="leftFrame"
scrollingAdd/remove scrollbar (yes, no, auto)scrolling="no"
noresizePrevents resizing this framenoresize
marginwidthSet left/right margin in pixels inside framemarginwidth="20"
marginheightSet top/bottom margin in pixels inside framemarginheight="15"
frameborderShow/hide border (1 = show, 0 = hide)frameborder="1"
bordercolorBorder colorbordercolor="orange"

Examples

  1. <frame src="about.html"> shows about.html in the frame.
  2. <frame src="home.html" name="main"> gives the frame a name.
  3. <frame src="welcome.html" scrolling="no"> disables scroll.

🔗 6. Linking Between Frames

Frames get really powerful when you allow one frame’s links to open in another frame.
This is done by using the target attribute in anchor <a> tags.

Example

  • menu.html could contain:
    <a href="page1.html" target="rightFrame">Page 1</a>
    <a href="page2.html" target="rightFrame">Page 2</a>
    
  • frameset.html frames:
    <frameset cols="30%,70%">
      <frame src="menu.html" name="leftFrame">
      <frame src="welcome.html" name="rightFrame">
    </frameset>
    
    Observation:
    Clicking a menu link on left updates right-side content only.

Other Examples

  1. Navigation bar opens new articles in the main frame.
  2. "Contact Us" link opens contact form in right frame.
  3. Clicking a chapter shows details on right frame.

⚙️ 7. Nested Frames

Nested frames are when a <frameset> is placed inside another <frameset>.
This helps you create complex layouts.

Example

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

Explanation:

  • First, the screen is split horizontally (20% header, 80% rest).
  • Inside the lower 80%, it's further split vertically (25% menu, 75% content).

Other Examples

  1. Top area for logo, bottom split into side menu and content.
  2. Left third for navigation, right two-thirds split into top (news) and bottom (updates).
  3. Full screen split into header, then main body split into menu/content.

🚫 8. Important Note (Deprecation)

The <frameset> and <frame> tags are deprecated in HTML5.

  • Modern browsers may not support them well.
  • Today, people use CSS layouts and <iframe> tags for similar work.
  • If you’re building new websites, avoid frames, and use these modern techniques.

🧠 9. Comparison Table

FeatureFramesetFrame
PurposeCreates rows/columns for layoutDisplays content in each section
Used InMain HTML instead of <body>Only inside <frameset>
Attributesrows, cols, border, etc.src, name, scrolling, noresize, marginwidth
Example<frameset cols="50%,50%"><frame src="main.html" name="main">

🧩 10. Example: Complete Frame Layout

<html>
<head><title>Frames Example</title></head>

<frameset rows="20%,80%">
  <frame src="header.html" name="topFrame" noresize>
  <frameset cols="30%,70%">
    <frame src="menu.html" name="leftFrame">
    <frame src="content.html" name="rightFrame">
  </frameset>
</frameset>

</html>

Explanation:

  • The window is split into two horizontal parts (top 20%, bottom 80%).
  • Top 20% shows header.
  • Bottom 80% is further split into left 30% (menu) and right 70% (content).

📘 Summary Table

ConceptDescription
FramesDivide webpage into multiple windows (sections), each with different HTML
Frameset TagDefines rows/columns (layout of frames)
Frame TagShows a specific HTML in a frame
LinkingUse target attribute to open pages in another frame
Modern AlternativeCSS and <iframe>
HTML5 SupportFrames are deprecated; use <iframe>

Fun Fact!

Frames were once very popular, but today, websites are responsive and dynamic using CSS grids and flex layouts!
Frames can be a little tricky for mobile screens and accessibility, so we use new methods now.


Scenario Based Questions

  1. Scenario: Your school's website shows a fixed men...