How are the `colspan` and `rowspan` attributes different?

Publikováno: 15.8.2024

Yes, yes. Functionally, they are different. But heck if I didn’t know about the wacky thresholds until Jens Oliver Meiert tooted a pair of quick polls.

According to the HTML Standard:

  1. If the current cell has a colspan attribute, then 


How are the `colspan` and `rowspan` attributes different? originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

Celý článek

Yes, yes. Functionally, they are different. But heck if I didn’t know about the wacky thresholds until Jens Oliver Meiert tooted a pair of quick polls.

According to the HTML Standard:

  1. If the current cell has a colspan attribute, then parse that attribute’s value, and let colspan be the result.
    If parsing that value failed, or returned zero, or if the attribute is absent, then let colspan be 1, instead.
    If colspan is greater than 1000, let it be 1000 instead.
  2. If the current cell has a rowspan attribute, then parse that attribute’s value, and let rowspan be the result.
    If parsing that value failed or if the attribute is absent, then let rowspan be 1, instead.
    If rowspan is greater than 65534, let it be 65534 instead.

I saw the answers in advance and know I’d have flubbed rowspan. Apparently, 1000 table columns are plenty of columns to span at once, while 65534 is the magic number for clamping how many rows we can span at a time. Why is the sweet spot for rowspan 6,4543 spans greater than colspan? There are usually good reasons for these things.

What that reason is, darned if I know, but now I have a little nugget for cocktail chatter in my back pocket.


How are the `colspan` and `rowspan` attributes different? originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace