Safari and Chrome ignore min-width CSS propery

17,858

Solution 1

Chrome and Safari simply do not support the min-width property on table elements. They will, however, respect min-width when applied to table cells.

After some quick testing, it appears that support is as follows:

  • Firefox: Supported (tested in 5, not sure since which version)
  • Internet Explorer: Supported (since IE8. IE7 and below do not seem to support it)
  • Chrome: Not supported (all versions as far as I can tell)
  • Safari: Not supported (all versions as far as I can tell)
  • Opera: Supported (tested in 11.5, not sure since which version)

More information can be found in the MDN article on the property, although the article claims that the property is not supported in IE, even though it is since IE8.

The CSS2.1 specification states that min-width (and max-width for that matter) apply to:

all elements but non-replaced inline elements, table rows, and row groups

So it would seem that Chrome and Safari are the ones not conforming to the standard.

Edit

Having just looked a bit further down the relevant section of the spec, I noticed it then states:

In CSS 2.1, the effect of 'min-width' and 'max-width' on tables, inline tables, table cells, table columns, and column groups is undefined.

So it actually looks like no-one got it wrong, and everyone can just do their own thing.

Solution 2

In my experience, it's often impractical to define widths on td elements. The best workaround I've found for this limitation is to set a min-width on a containing div element for the table.

Share:
17,858

Related videos on Youtube

dev.e.loper
Author by

dev.e.loper

Updated on June 04, 2022

Comments

  • dev.e.loper
    dev.e.loper almost 2 years

    Why do Safari and Chrome ignore min-width CSS property? Example http://jsfiddle.net/8YFHu/2/ This works in IE and Firefox but not in Safari and Chrome.

  • James Allardice
    James Allardice almost 12 years
    Update - It appears that Chrome now does support this. I'm not sure since when this is the case, but I just tested it in Chrome 19.
  • The Oddler
    The Oddler over 6 years
    I noticed that Chrome seems to support it when setting the min-width to some number of pixels, but doesn't when setting it to a percentage value. Firefox does in both cases.