Reply to topic
Going Tableless
darnold


Joined: 17 Mar 2005
Posts: 21
Reply with quote
Tableless design is something that every designer should know how to do. I've vowed to create all apps without the use a single table and have learned a lot good xhtml / css along the way. The most valuable lesson for me was gaining a basic understanding of the css float attribute.


Reply to this post to share your css tips for going tableless.

Post your table and I'll show you how to do it with less actually code using divs.

The internet will be a better place for it.


Very Happy
darnold


Joined: 17 Mar 2005
Posts: 21
Reply with quote
Here is an example of using tables. This is the output from photoshop after slicing up an image. Below it will be the same thing after I converted to tableless design.

Code:
<table id="Table_01" width="248" height="355" border="0" cellpadding="0" cellspacing="0">
   <tr>
      <td colspan="6">
         <img src="images/calcTables_01.jpg" width="248" height="22" alt=""></td>
   </tr>
   <tr>
      <td>
         <img src="images/calcTables_02.jpg" width="20" height="50" alt=""></td>
      <td colspan="4">
         <img src="images/calcTables_03.jpg" width="205" height="50" alt=""></td>
      <td>
         <img src="images/calcTables_04.jpg" width="23" height="50" alt=""></td>
   </tr>
   <tr>
      <td colspan="6">
         <img src="images/calcTables_05.jpg" width="248" height="22" alt=""></td>
   </tr>
   <tr>
      <td colspan="2">
         <img src="images/calcTables_06.jpg" width="30" height="68" alt=""></td>
      <td>
         <img src="images/calcTables_07.jpg" width="184" height="68" alt=""></td>
      <td>
         <img src="images/calcTables_08.jpg" width="1" height="68" alt=""></td>
      <td colspan="2">
         <img src="images/calcTables_09.jpg" width="33" height="68" alt=""></td>
   </tr>
   <tr>
      <td colspan="2">
         <img src="images/calcTables_10.jpg" width="30" height="64" alt=""></td>
      <td colspan="2">
         <img src="images/calcTables_11.jpg" width="185" height="64" alt=""></td>
      <td colspan="2">
         <img src="images/calcTables_12.jpg" width="33" height="64" alt=""></td>
   </tr>
   <tr>
      <td colspan="2">
         <img src="images/calcTables_13.jpg" width="30" height="74" alt=""></td>
      <td colspan="2">
         <img src="images/calcTables_14.jpg" width="185" height="74" alt=""></td>
      <td colspan="2">
         <img src="images/calcTables_15.jpg" width="33" height="74" alt=""></td>
   </tr>
   <tr>
      <td colspan="6">
         <img src="images/calcTables_16.jpg" width="248" height="54" alt=""></td>
   </tr>
   <tr>
      <td>
         <img src="images/spacer.gif" width="20" height="1" alt=""></td>
      <td>
         <img src="images/spacer.gif" width="10" height="1" alt=""></td>
      <td>
         <img src="images/spacer.gif" width="184" height="1" alt=""></td>
      <td>
         <img src="images/spacer.gif" width="1" height="1" alt=""></td>
      <td>
         <img src="images/spacer.gif" width="10" height="1" alt=""></td>
      <td>
         <img src="images/spacer.gif" width="23" height="1" alt=""></td>
   </tr>
</table>



Going tableless means less code in your html. It is easier for text based browsers to understand and puts all the definitions in an external style sheet. This means removing the need to edit your html later on. Using this method allows you to edit your style sheet instead.



Code:
<div id="calculatorWrapper">
   <div id="calcTop"></div>
    <div id="calc02"></div><div id="calc03"></div><div id="calc04"></div>
    <div id="calc05"></div>
   <div class="calcBtn1"></div><div class="calcBtn2"></div><div class="calcBtn3"></div>
    <div class="calcBtn1"></div><div class="calcBtn2"></div><div class="calcBtn3"></div>
    <div class="calcBtn1"></div><div class="calcBtn2"></div><div class="calcBtn3"></div>
   <div id="calcBottom"></div>
</div>



Now isn't that much nicer.


Here is the css required.


Code:
#calculatorWrapper {
   width:248px;
   height:319px;
   display:block;
   position:relative;
   margin-left:auto;
   margin-right:auto;
   }

#calcTop {
   background-image:url(../images/calculator_01.jpg);
   width:248px;
   height:22px;
   }

#calc02 {
   background-image:url(../images/calculator_02.jpg);
   width:20px;
   height:50px;
   float:left;
   }

   
#calc03 {
   background-image:url(../images/calculator_03.jpg);
   width:205px;
   height:50px;
   float:left;
   }
   
#calc04 {
   background-image:url(../images/calculator_04.jpg);
   width:23px;
   height:50px;
   float:left;
   }

#calc05 {
   clear:left;
   background-image:url(../images/calculator_05.jpg);
   width:248px;
   height:22px;
   }

.calcBtn1 {
   float:left;
   background-image:url(../images/calculator_10.jpg);
   width:30px;
   height:64px;
   }
.calcBtn2 {
   float:left;
   background-image:url(../images/calculator_11.jpg);
   width:185px;
   height:64px;
   }
.calcBtn3 {
   float:left;
   background-image:url(../images/calculator_12.jpg);
   width:33px;
   height:64px;
   }

#calcBottom {
   clear:left;
   background-image:url(../images/calculator_16.jpg);
   width:248px;
   height:54px;
   }



You can see this code live in action here. I've used it to for designing a form. And inserted form elements in between the div tags.

http://laweightlosssurgery.com/bmic.html
Going Tableless
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic