Hacker News new | ask | show | jobs
by bajsejohannes 3061 days ago
Any idea why the grid is 1-indexed instead of 0-indexed?
2 comments

I believe it's so that you can use -1 to refer to the last gridline. If it was 0-indexed there would be no way to target that final gridline, or there would be a one-off error when using negative numbers.

Example: https://css-tricks.com/things-ive-learned-css-grid-layout/#a...

Couldn't you still use -1 to refer to the last grid line (or was it grid element)? Python does it, for example.
Yes, but that would mean the first gridline == 0 and the last gridline == -1, instead of the way the spec is written today, where the first gridline == 1 and the last gridline == -1. For me, consistency wins here.
It's much more intuitive for non-programmers, which make up the majority of HTML/CSS users.