Search code examples
htmlcss-tables

Html table - how to force TD width when table width is 100%?


Is there a way to set the length of all TD cells in case when whole table width is set to 100%? In other words I want all table cells moved to the left (but I can't change table width, because this is for other purposes).

I tried in this way:

#mytable td {
    width:50px;
}

But this is not working when table width is set to 100%. Here is an example how this looks now: http://jsfiddle.net/Rrkky/


Solution

  • You cannot make 50px plus 50px equal 100% of the available width except by accident. If you just want to put the table on the right, set e.g. margin-left: auto on it. But this would not work if the table width is set to 100%.