Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problems with Tables and CSS

Featured Replies

Hi Guys

 

I'm trying to sort out the table for the packages but I'm having real trouble :(

 

http://www.specialhosting.co.uk/hosting.html

 

The data in the first column is stuck to the border !! I don't know how to make it unstuck.

 

Also in Firefox I get something and in IE8 I get something totally different :(

 

I want the table to look the same in both browsers .. Firefox and IE8.

 

please help.

 

Thank You.

Your left col is a th while the others are td, although they all have the same class="thcolalt"

 

Add text-align: center; to the th style (the td style has it):-

 

th { font-weight:normal; text-align: center;

padding: 0.7em 0;

border-right:1px solid #303030;

border-left:1px solid #303030;

border-bottom:1px solid #303030;

border-top:1px solid #303030; }

And if IE8 is being a pain in the ass just add: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

below your <head> which will render as if in IE7.

  • Author

@Wickham: I just did that .. but that just centers the text within the first column !

 

I didn't want it centered .. I just wanted a little padding to its left so that it wasn't touching the left border of the table :(

 

Ohh by the way .. why is IE8 showing the text within that first column as centered even though I have added that text-align: center; to the th ?? :search:

Did you use the "cellpadding" attribute? 

First, let me point out that you're missing the opening table tag; your table code just has an ending table tag (</table>). When you add the opening table tag, you can use the cellpadding attribute to increase the amount of space within the cells.

 

Here's what you should have:

 

<table cellpadding="whatever">

<tr>
     <th width="28%"></th>
     <th width="18%"><h2 align="center">Basic</h2></th>
     <th width="18%"><h2 align="center">Advanced</h2></th>
     <th width="18%"><h2 align="center">Premium</h2></th>
     <th width="18%"><h2 align="center">Reseller</h2></th>
   </tr>

   <tr>
     <th class="thcolalt">Web Space</span></th>

     <td class="thcolalt"><strong>1,000 MB's</strong></td>
     <td class="thcolalt"><strong>3,000 MB's</strong></td>
     <td class="thcolalt"><strong>5,000 MB's</strong></td>
     <td class="thcolalt"><strong>15,000 MB's</strong></td>
   </tr>
   <tr>
     <th class="thcolalt">Bandwidth</th>

     <td class="thcolalt"><strong>3,000 MB's </strong></td>
     <td class="thcolalt"><strong>5,000 MB's</strong></td>
     <td class="thcolalt"><strong>10,000 MB's</strong></td>
     <td class="thcolalt"><strong>40,000 MB's</strong></td>
   </tr>
   <tr>
     <th class="thcol"><strong>Free</strong> UK Domain Name</th>

     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
   </tr>
   <tr>
     <th>Domains you can host on Webspace </th>
     <td>1</td>

     <td>2</td>
     <td>10</td>
     <td>Unlimited</td>
   </tr>

   <tr>
     <th>Sub-Domains</th>
     <td><img src="images/cross.png" alt="none" width="32" height="32" /></td>

     <td>5</td>
     <td>25</td>
     <td>Unlimited</td>
   </tr>
   <tr>
     <th class="thcol">PHP 5 & MySQL 5 </th>

     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
   </tr>
   <tr>
     <th>MySQL Databases </th>
     <td>1</td>

     <td>5</td>
     <td>25</td>
     <td>100</td>
   </tr>
   <tr>
     <th class="thcol">Email Accounts </th>
     <td>10</td>

     <td>100</td>
     <td>250</td>
     <td>Unlimited</td>
   </tr>

   <tr>
     <th>Web Site Builder</th>
     <td><img src="images/tick.png" alt="Included" /></td>

     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
   </tr>
   <tr>
     <th>SSH Access </th>
     <td><img src="images/cross.png" alt="none" width="32" height="32" /></td>
     <td><img src="images/cross.png" alt="none" width="32" height="32" /></td>

     <td><img src="images/cross.png" alt="none" width="32" height="32" /></td>
     <td><img src="images/tick.png" alt="Included" /></td>
   </tr>


   <tr>
     <th class="thcol">Monthly Price </th>
     <td><strong>£1.99 / month</strong></td>
     <td><strong>£3.99 / month</strong></td>

     <td><strong>£4.99 / month</strong></td>
     <td><strong>£14.99 / month</strong></td>
   </tr>
   <tr>
     <th class="thcol"> </th>
     <td><div align="center"><a href="#"><img src="images/button2.jpg" alt="Sign Up Now" border="0" /></a></div></td>
     <td><div align="center"><a href="#"><img src="images/button2.jpg" alt="Sign Up Now" border="0" /></a></div></td>
     <td><div align="center"><a href="#"><img src="images/button2.jpg" alt="Sign Up Now" border="0" /></a></div></td>

     <td><div align="center"><a href="#"><img src="images/button2.jpg" alt="Sign Up Now" border="0" /></a></div></td>
   </tr>
 </table>

 

 

Notice how I added the opening table tag at the very beginning of the code.

 

 

 

  • Author

I've just checked my code ... I do have an opening tag for the table !!

 

<table id="compareplans">

 

I managed to do the padding by the way ! But I still don't know why IE shows the text in the first column as Centered !!

 

I do not want the text centered .. I want it on the left like in FireFox 3.5

 

I'd greatly appreciate any further help with this

 

Thanks

If you don't want the left th column centered you could use cellpadding but that is the clumsy old method of coding which will affect the whole table. Stay with <table id="compareplans">. You already have top and bottom padding, just add side padding:-

 

th { font-weight:normal;

padding: 0.7em 20px; /*was 0.7em 0;*/

border-right:1px solid #303030;

border-left:1px solid #303030;

border-bottom:1px solid #303030;

border-top:1px solid #303030; }

 

That works in IE7 and should work in IE8.

 

The id for the whole table has text-align: left;

#compareplans { font-size: 1.4em; text-align:left; border-collapse:collapse; margin-left:auto;margin-right:auto; width:90%;}

 

but that is overridden in the td style by text-align: center;

 

It will apply to the th left column and then the padding edit will keep the text away from the left side.

  • Author

Hi Wickham

 

I just tried that .. but it didn't work ! So I decided to make a backup and play around with things !! Something I've never done before .. I'm always scared to mess stuff up.

 

Anyways .. I managed to do it. Now I want IE to display the table the exact way that I want it displayed.

 

check it out !

 

http://www.specialhosting.co.uk

 

Thanks for all the help guys :)

On your hosting.html page the left column looks the same now in IE7, IE8 and Firefox with a small amount of padding on the left. You have done what I suggested with the revised style

th { font-weight:normal;

padding: 0.7em 0.5em;

border-right:1px solid #181818;

border-left:1px solid #181818;

border-bottom:1px solid #181818;

border-top:1px solid #181818; }

 

using 0.5em instead of my 20px.

  • Author

Yep but that on its own didn't work .. that is why I had to add some other classes to the CSS.

 

Thanks for all the help Wickham :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.