Re: [csswg-drafts] [css2][css-tables] Should tables re-resolve their margins after shrinking due to `visibility: collapse`? (#11408)

What Gecko does is: it shrinks the table grid box, but not the table wrapper box. That's why margins are unaffected, or here the table doesn't fit next to the float:

```html
<!DOCTYPE html>
<div style="border: solid; width: 150px">
  <div style="float: left; width: 75px; height: 50px; background: magenta"></div>
  <table style="width: 100px; height: 50px; border-spacing: 0; background: cyan">
    <col style="visibility: collapse"></col>
    <td></td>
    <td></td>
  </table>
</div>
```

| Gecko | Blink |
| - | - |
| ![](https://github.com/user-attachments/assets/eef97b7d-cd9c-4447-b4b1-bd0e25a2b2cb) | ![imatge](https://github.com/user-attachments/assets/174e356d-c1e4-484b-ba7f-c5bf4a490763) |

That the table wrapper doesn't shrink can be observed with outline. And it's possible to align the table grid box to the right of the table wrapper box with `direction: rtl`:

```html
<!DOCTYPE html>
<div style="border: 6px solid; width: 150px">
  <table style="width: 100px; height: 50px; border-spacing: 0; background: cyan; outline: solid magenta; direction: ltr;">
    <col style="visibility: collapse"></col>
    <td></td><td></td>
  </table>
  <table style="width: 100px; height: 50px; border-spacing: 0; background: cyan; outline: solid magenta; direction: rtl;">
    <col style="visibility: collapse"></col>
    <td></td><td></td>
  </table>
</div>
```

| Gecko | Blink |
| - | - |
| ![](https://github.com/user-attachments/assets/d593852d-eb5a-4833-a6f8-75f227e87ef5) | ![](https://github.com/user-attachments/assets/d970d228-1b43-445e-8092-68f9cf809eba) |

I think both can be reasonable, but since Gecko allows the wrapper to be bigger than the grid (it can also happen with a caption, but Blink & WebKit never allow it), it should be possible to customize the alignment with `justify-items` (it would apply to the table wrapper, and affect the table grid that would get the initial `justify-self: auto`

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11408#issuecomment-2558765641 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 23 December 2024 02:11:34 UTC