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
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
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>
The following should work:
<table style="width:300px;table-layout:fixed"></table>
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>