Style Sheets
  Home arrow Style Sheets arrow Page 3 - Designing Web Pages without Tables
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Designing Web Pages without Tables
By: Sasha Slutsker
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 69
    2004-08-09

    Table of Contents:
  • Designing Web Pages without Tables
  • No Tables for Layout
  • Absolute Positioning, Add Borders and Margins
  • Lack of Browser Support

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Designing Web Pages without Tables - Absolute Positioning, Add Borders and Margins


    (Page 3 of 4 )

    Absolute Positioning means that you define exactly where on the screen your element to appear. This is done by defining top, bottom, left, and right attributes like so:

    div.content{

    background: white;

    color: black;

    position: absolute; /* Says which positioning we are using */

    left: 17%; /* 17% from the left side of the screen */

    width: 69%; /* This is the width */

    }

    Note that only the left property was defined. This is okay! You do not need to define all the properties, but for more flexibility, you might want to. For example, you may want to add a menu on the right:

    div.rightnav{

    background: white;

    color: black;

    position: absolute;

    left: 83%;

    width: 10%;

    top: 80px; /* 80 pixels from the top */

    }

    Basically, in absolute positioning, the elements mean this:

    left: distance from left side of screen, usually percent

    right: distance from right side of screen, usually percent

    top: distance from top of screen, usually pixels

    bottom: distance from bottom screen, usually pixels

    Note that bottom is rarely used, but it is needed sometimes. If you do use all four (or at least three) of the elements, you should be able to put the div tag anywhere you want. Also, it is important to note that there are more ways to position an element besides absolute positioning, but not all browsers support those ways. For example, there is also fixed positioning, but this is not supported by Internet Explorer (IE). Therefore, you should probably just use absolute positioning.

    Adding Borders

    You may want to space your element a little from the sides of the screen or something. Borders are good for this, but remember to test your code in different browsers as this can be a little tricky. More information about that is on the next page, though. On this page you will just find out about how to make the borders.

    div.rightnav{

    background: white;

    color: black;

    position: absolute;

    left: 83%;

    width: 10%;

    top: 80px; /* 80 pixels from the top */

    border-color: white; /* Keep the border invisible */

    border-style: solid; /* It is a solid invisible line which is fine */

    border-bottom-width: 2px; /* These attributes are pretty self-explanatory */

    border-top-width: 2px;

    border-left-width: 3px;

    border-right-width: 4px;

    }

    Adding Margins

    Margins are a great tool for any CSS Website. Basically, you can put something in the center by putting it a certain percentage from both margins. Here is how it is done:

    div.content{

    background: white;

    color: black;

    margin-left: 20%; /* 20% from the left side of the screen */

    margin-right: 20%; /* 20% from the right side of the screen */

    }

    More Style Sheets Articles
    More By Sasha Slutsker


       · Since ALL browsers use table consistently, and not all browsers use CSS...
       · You keep using tables, and the rest of us will take what you call a job. Oh, and if...
       · you are right to continue to use tables for now. A year or two down the road, CSS...
       · that's Netscape 4.7
       · Looks like tables are still good enough for Dev Shed sites.
       · I decided to put the table/css debate aside for a moment to try creating the css...
       · unless your designing for an intranet where you can control the browsers used, stick...
       · You need to add the CSS code that defines the content, rightnav, and leftnav...
       · Also, you can see an example of a site written in completely valid XHTML/CSS here:...
       · The Solar Conflict site is simple yet elegant. It taught me all I need to know to...
       · Yes you can make really good web sites with CSS : but if you want to know how to do,...
       · For my site, I've used the display: inline and display: table-cell commands, to get...
       · This site is "devoted" totally to css and shows how flexible it really can be in the...
       · I forgot exactly the code I used, but try something like border-margin:0; it could...
       · but it is aggravating that IE renders pages so differently than all the other...
       · 
       · It's easy to label developers that still use tables as ignorant and afraid of...
       · Actually I find that when I'm trying to make pages accessible CSS is more of a help...
       · Actually I find that when I'm trying to make pages accessible CSS is more of a help...
       · Um, Sasha, did you know your name reads Sasha Slut in the article listing? Call me...
       · The opening css design on "zen garden" renders terribly in IE5.0. To be specific,...
       · I'm curious. Am I the only one that uses CSS with tables? I used divs too, but it...
       · I too have seen the ramifications of IE being way to forgiving and Netscape seeming...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek