tirenweb
tirenweb

Reputation: 31709

Give width to th element doesn't work for me

I have this table, and I want to give a width to a th element, but it doesn't work..

     <th style="width: 400px">
        Room type                                    
     </th>

Any help?

Upvotes: 1

Views: 202

Answers (5)

jdtaylor
jdtaylor

Reputation: 334

Due to your table being wide the width tag is not sufficient, use min-width instead.

<th style="min-width: 300px;" />

I would also recommend using colgroups if you are planning on setting a number of different widths in your headers - makes it easier to maintain and keeps it in one place.

Upvotes: 0

Andrea Ligios
Andrea Ligios

Reputation: 50193

Use min-width, display: inline-block; or display: block;.

I think the first is the best...

Upvotes: 0

user900202
user900202

Reputation:

your table is too short to give width to the th.. delete some columns or just enlarge your table width. like:

<table width="2000px">

Upvotes: 0

Mr. Alien
Mr. Alien

Reputation: 157284

It does work, it's just that there's no room for the th to get 300px width, use min-width instead

Demo

Another Demo

Upvotes: 3

Roman K
Roman K

Reputation: 3337

use min-width instead of width

Upvotes: 0

Related Questions