tags:

views:

30

answers:

3

I have a table with dynamic data.

Depending on data,it expands or collapses.

I dont want it.I want a fixed width that never expand or collapse.

How can i do that?

I've already try <table width="300px"></table>

but doenst work

A: 

Either old ugly way

<table width="300"></table>

or the CSS way

<table style="width:300px"></table>

Of course, the best way is to use a separate stylesheet file, call it for example style.css:

table {
  width: 300px;
}

and your html document:

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="style.css"/>
  </head>
  <body>
    <table>
    ...
    </table>
  </body>
</html>
Johan
no,thats not quite.it keeps changing
+1  A: 

The following should work:

<table style="width:300px;table-layout:fixed"></table>
ironsam
man,it works!but it not follow 300 width,damn it
Is it larger or smaller then 300? Do you have padding, spacing, margins, or borders on the table?
ironsam
A: 

You'd set the width of each column explicitly like so:

td.a {
   width:100px;
}
td.b { 
   width:200px;
}
...

<table>
<tr><td class='a'>A</td><td class='b'>B</td></tr>
<tr><td class='a'>A</td><td class='b'>B</td></tr>
<tr><td class='a'>A</td><td class='b'>B</td></tr>
<tr><td class='a'>A</td><td class='b'>B</td></tr>
</table>
Dave Markle