Results 1 to 5 of 5

Thread: how to set the width of colomn inside a table

  1. #1
    Join Date
    Apr 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to set the width of colomn inside a table

    hi to all


    i want to know how to set the width of column inside a table. i mean to say, in my program i am displaying employee details. inorder to display details i used table. when ever the size of the text more the hight of each coloun increasing. thats why i want to set a fixed size so that all different sizes of texts will fit into that column.


    regards

  2. #2
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you can try something like this:
    <td width="25&#37;">
    and just change the percentage to whatever fits your needs

  3. #3
    Join Date
    Apr 2007
    Location
    Phoenix, AZ
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Even if you're using a table, it's still best to set the presentational attributes via CSS:

    Code:
    td.details  {
      width:25&#37;;
      }
    
    ...
    
    <table>
      <tr>
        <td class="name">Employee Name</td>
        <td class="details">...</td>
      </tr>
    </table>
    You can set the width of the column in both relative and fixed terms. Use % if you want the column to get bigger when the page is resized horizontally (like above).

    Use em if you want the column to always stay proportional to the size of the text. (This is often the best if your layout is flexible)-- width:30em;

    And use px if you want the column to just stay the same size-- width:250px;

  4. #4
    Join Date
    Mar 2007
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    instead of a <td> in the first row, use a <th> you can then assign width to that column

  5. #5
    Join Date
    Apr 2007
    Location
    Phoenix, AZ
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Good idea. Then you can also control the look of the header column with your CSS, separately from the style of the rest of the table.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •