Categories: css-tricks.com

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

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.

hnikoloski

Share
Published by
hnikoloski

Recent Posts

Quick Hit #21

Seeing a lot more headlines decrying JavaScript and pumping up PHP. Always interesting to see…

18 hours ago

CSSWG Minutes Telecon (2024-09-18)

For the past two months, all my livelihood has gone towards reading, researching, understanding, writing,…

19 hours ago

Quick Hit #20

Having fun with Bramus’ new Caniuse CLI tool. This’ll save lots of trips to the…

2 days ago

Quick Hit #19

Two possible syntaxes for CSS masonry, one draft specification, and you get to share your…

2 days ago

Re-Working the CSS Almanac

Getting right to it: the CSS-Tricks Almanac got a big refresh this week! I’m guessing…

2 days ago

Clever Polypane Debugging Features I’m Loving

I’m working on a refresh of my personal website, what I’m calling the HD remaster.…

4 days ago