Home » questions » HTML design - Want table to have set width on left AND right with the center variable?

HTML design - Want table to have set width on left AND right with the center variable?

2006-08-02 06:42:40, Category: Programming & Design
Every time I try to do this, it doesn't work. I want a set widht for left and right columns and the middle column to be variable width depending on the page width. I don't want to use table-less design. I have tried setting the width property in the TD tags and using stylsheets, but neither seems to work. Unfortunately, my table is already 100% and I set widths for the two outer columns while trying * and nothing for the middle width and it didn't work. Tim G may be right that it will always give more room to the outer ones when there's not enough content in the middle, but if that's the case. I may try the left and right aligned tables instead. Perhaps using float. I'll let you know how it worked.

Answers

  1. pr_helpdesk

    On 2006-08-02 06:48:03


    Try this: create a single-cell table with the desired width and left-align it. Now create another and right-align it. Does this give you what you want?
  2. Joey

    On 2006-08-02 07:06:44


    123 122 2225
    basically assign a width to ur table of 100% they assign the widths to the columns (left and right) DO NOT assign a width to ur center td.
  3. Tim G

    On 2006-08-02 14:13:26


    In theory, some of the other posts here should work, but they won't, at least in most browsers. Here's the best way to do what you want.
      Variable content  
    Using the nowrap attribute assures that the margin will remain *at least* 10 pixels, or whatever width you assign it. If you assign a width to the table, and there isn't much content in the middle table cell, then the browser will give the margin cells extra space, even with the nowrap attribute. Nowrap just assures that the cell won't be any *smaller* than the width assigned to it. Using nowrap and leaving out the width tag in the table will take care of that problem. Depending on the layout of your site, you may want to center the table.
  4. Igi Bhoy

    On 2006-08-02 08:04:21


    joey is right. you can assign the table width="100%", left and right cells/column a static width such as 300. leave the middle column without a specified width. enjoy HTML, if you have questions feel free to ask we will be here to assist you.
  5. interested dude

    On 2006-08-02 06:47:06


    set your css to use 94% width and margins 0. this should give you 3% white space on either side of the centered table.
  6. ciaran_foley2003

    On 2006-08-02 08:49:21


    like they said - but if you use width="*" the center column will become flexible if that interests you at all. Although Im pretty sure thats depreciated now.