Skip to content

[css-tables][css-sizing] What sizing keywords allow fixed table mode? #10937

Closed

Description

@Loirooriol

Situation

https://drafts.csswg.org/css-tables/#table-layout-property says

A table-root is said to be laid out in fixed mode whenever the computed value of the table-layout property is equal to fixed, and the specified width of the table root is either a <length-percentage>, min-content or fit-content.

This is the logic that browsers use for the inline size:

So we have a mismatch of keywords that accept fixed table layout:

Value Spec WebKit Gecko Blink
<length-percentage> ✅ ✅ ✅ ✅
auto ❌ ❌ ❌ ❌
min-content (*) ✅ ✅ ✅ ✅
max-content (*) ❌ ❌ ❌ ❌
fit-content (*) ✅ ✅ ✅ ✅
<fit-content()> ❌ ❌︎ ✅ ✅︎
contain ❌ ❌︎ ✅︎ ✅︎
stretch ❌ ❌︎ ✅ ✅︎
-webkit-fill-available ❌︎ ❌ ✅ ✅
-moz-available ❌︎ ❌︎ ✅ ✅︎
intrinsic ❌︎ ❌ ✅︎ ✅︎
min-intrinsic ❌︎ ❌ ✅︎ ✅︎

<calc-size()> should just behave as its basis.

(*) including -webkit- and -moz- prefixes.
✅: Supports the value (at least partially), and allows fixed table layout
✅︎: Doesn't support the value, but it would allow fixed table layout
❌: Supports the value (at least partially), and doesn't allows fixed table layout
❌︎: Doesn't support the value, but it wouldn't allow fixed table layout

Example

<!DOCTYPE html>
<div style="width: 0">
  <table style="table-layout: fixed; width: -webkit-fill-available" border>
    <tr><td>lorem ipsum</td></tr>
  </table>
</div>

On Firefox (with layout.css.webkit-fill-available.enabled = true) and Blink the table ignores the contents and is almost 0px wide, while on WebKit it's wider according to the text.

Changes

I think that <fit-content()> should allow fixed table layout, just like fit-content and min-content.

And maybe stretch should too, to match 100%? Also, -webkit-fill-available/-moz-available is kinda the same thing, and it allows fixed table layout on 2/3 of the major browsers.

Nobody implements contain, but we should also decide what to do with it.

Activity

  1. bfgeek commented on Sep 24, 2024

    @bfgeek

    As an aside does anyone know what max-content doesn't apply?

    (FWIW the "rule" that we've been applying to to a lot of these table behaviours, is if "width is auto" do the special behaviour - this comes up a suprising amount in table layout).

  2. Loirooriol commented on Sep 24, 2024

    @Loirooriol
    ContributorAuthor

    Yeah, it's kinda weird that, given enough available space, fit-content doesn't behave like max-content:

    <!DOCTYPE html>
    <div style="width: max-content">
      <table style="table-layout: fixed; width: max-content" border>
        <tr><td style="width: 0">lorem ipsum</td></tr>
      </table>
      <table style="table-layout: fixed; width: fit-content" border>
        <tr><td style="width: 0">lorem ipsum</td></tr>
      </table>
    </div>

    Only checking for auto would make this more future-proof.

  3. Loirooriol commented on Sep 27, 2024

    @Loirooriol
    ContributorAuthor

    There was a broken test in https://github.com/web-platform-tests/wpt/blob/master/css/css-tables/fixed-layout-2.html, I have fixed it and tested all the cases above to help with interoperability.

  4. Loirooriol commented on Oct 5, 2024

    @Loirooriol
    ContributorAuthor

    WebKit/WebKit#34706 aligned -webkit-fill-available with Blink and Gecko.

  5. moved this to FTF agenda items in CSSWG January 2025 meetingon Jan 22, 2025
  6. moved this from FTF agenda items to Regular agenda items in CSSWG January 2025 meetingon Jan 22, 2025
  7. moved this from Regular agenda items to Friday morning in CSSWG January 2025 meetingon Jan 28, 2025
  8. 31 remaining items

  9. tabatkins commented on Jun 23, 2025

    @tabatkins
    Member

    So just verifying - you're saying the resolution needs to be changed so that "auto" table layout is triggered by an auto or max-content width, and "fixed" layout is triggered for everything else?

  10. bfgeek commented on Jun 23, 2025

    @bfgeek

    So just verifying - you're saying the resolution needs to be changed so that "auto" table layout is triggered by an auto or max-content width, and "fixed" layout is triggered for everything else?

    Yup thats right.

  11. css-meeting-bot commented on Sep 24, 2025

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-tables][css-sizing] What sizing keywords allow fixed table mode?, and agreed to the following:

    • RESOLVED: width:max-content prevents table-layout:fixed from working
    The full IRC log of that discussion <TabAtkins> iank_: we had a resolution to just have width:auto trigger fixed table layout
    <TabAtkins> iank_: this isn't web-compat, there's a library that sets width:max-content on tables and assumes they'll go into fixed mode
    <TabAtkins> iank_: so my proposal is we have width:auto *or* max-content, we trigger fixed layout.
    <TabAtkins> iank_: not including a calc-size(), it's those keywords literally
    <TabAtkins> astearns: so just adding one more condition to the list?
    <TabAtkins> iank_: yes
    <TabAtkins> oriol: correction, auto/max-content *prevent* fixed layout.
    <TabAtkins> fantasai: so you can set table-layout to fixed or auto. if you set 'fixed', but width is 'auto' (or, proposed, max-content), you'll instead get auto layout.
    <TabAtkins> fantasai: can we instead just say that only extrinsic sizes allow fixed?
    <TabAtkins> iank_: no, doesn't work
    <TabAtkins> oriol: also if we add more conditions it's harder to opt into this behavior
    <emilio> So we're resolving on Gecko's behavior right?
    <TabAtkins> astearns: so proposed resolution: add max-content to the list of exceptions that prevent table-layout:fixed
    <TabAtkins> iank_: I believe yes, gecko's behavior
    <TabAtkins> RESOLVED: width:max-content prevents table-layout:fixed from working
  12. Loirooriol commented on Sep 1, 2026

    @Loirooriol
    ContributorAuthor

    So I did this as it matches the "not initial" we've done for other cases in table layout.

    @bfgeek Now that it's no longer "not initial", do you think calc-size() should behave as its base?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions