开发者

How to set default width for the <th> and <td>?

I want to know how ca开发者_如何学Gon I set my desired width for all the and in my tables. What happens is that when I declare something like <th> Employee Code </th>, it will separate the Employee and Code and creating two lines. This usually happens when the data is shorter than the table header. I want to make my table go wider when the table data is long and not go taller like what is happening right now. Please help...


You can enclose the parts that you don't want broken across the line with a <nobr> </nobr> tag. The browser will not wrap this part of the text.


You can use the Colspan property like <th COLSPAN=2> Employee Code </th> Colspan indicates the number of columns a cell should take up. There is also Rowspan property.


use css:

table.mytable th
{
 height:20px;
 text-align:center;
 font-weight:bold;
 font-family:arial;
 font-size:12px;
 background-color:yellow;
 width:100px;
}


table.mytable td
{
 height:20px;
 text-align:center;
 font-weight:bold;
 font-family:arial;
 font-size:12px;
 width:100px;
}


The CSS attribute min-width was designed for this and compatibility is good. Except for IE6.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜