1. Home
  2. Computing & Technology
  3. Web Design / HTML

"Framed" Pages without Frames - CSS
Using CSS Positioning to Create Frame-like Pages

By , About.com Guide

In a previous article, I discussed how to use CSS positioning to create a tableless layout. Using CSS in this way will ensure that your XHTML is valid - as it is incorrect to use tables for anything other than displaying tabular data. But there is a way to play with positioning and a CSS2 property called "overflow" to make your pages resemble frames, not just tables.

What is it About Frames?
If we're setting out to emulate frames, we need to determine what we want to emulate:

  • page is divided into sections
  • some sections scroll and some don't

It's easy to create a page that is divided into sections. We learned how to do that in that previous article. But to make that page we created look like a framed Web page, we need to add scrolling. Here's my sample "fake framed" page. (Note: this page was optimized for Mozilla 1 on Windows.) As you can see, I also added borders to make it look more like a framed page that hasn't had the borders turned off.

CSS overflow Property
The overflow property is the way I can get the page to scroll. This property has five different styles:

  • visible
    This is the default, and it indicates that the content should be displayed on the page as the browser normally would.
  • hidden
    This style indicates that any extra content that doesn't fit in the box should remain hidden.
  • scroll
    With the overflow set to scroll will add scrollbars (both vertical and horizontal) to the box property.
  • inherit
    The inherit style sets the overflow to be inherently the same as the parent element.
  • auto
    This is the style we want. It specifies that if the content will overflow the box, scrollbars should display, otherwise, they are left off.

I put the overflow : auto; on both the left navigation element (#leftnavigation) and the main content area (#content). That ensures that if the browser window is really small, both the navigation and the content will be scrollable.

As with the other page, this page might not look as nice in browsers that don't support CSS positioning. See the HTML. See the CSS. See it in Action.

Explore Web Design / HTML
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. CSS
  5. "Framed" Pages without Frames - Cascading Style Sheets (CSS)>

©2009 About.com, a part of The New York Times Company.

All rights reserved.