Keith L.
Keith L.

Reputation: 2124

HTML: fixed and variable width of tds

i have a <table> and many (34) <td>.

I want to display three variable cells e.g. "name", "hobby1", "hobby2" and then I need to display 31 cells (for each day).

The width of the <table> is limited to about 1000px.

In the day cells always a string of the length 3 shall be displayed or nothing.

My problem is that, the cells never have the same width even if set with css.

The first three columns may be fixed too.

How can I manage my table, that all day <td>s (1-31) have the same width - no matter if the content is nothing or XXX?

http://jsfiddle.net/sBYdu/

Upvotes: 1

Views: 1231

Answers (2)

j08691
j08691

Reputation: 207901

table {

    table-layout: fixed;
}

Upvotes: 0

Matt K
Matt K

Reputation: 6708

A couple of css additions can achieve this.

  • Use a fixed table-layout
  • Apply width to your table header not the table cell
  • Apply word wrapping to the table cells

http://jsfiddle.net/nnePW/

Upvotes: 3

Related Questions