Your accepted answer doesn't really explain what's going on. Temani Afif said in the comments, 'span 1 / span 1 is simply equal to span 1'. That is true, but it doesn't explain the purpose of Tailwind’s code, which is what your question seems to be asking.
So let's consider the span 2 / span 2
example. This is the value of the grid-column
property, which is just shorthand for the grid-column-start
and grid-column-end
properties. It could also be written like this:
grid-column-start: span 2;
grid-column-end: span 2;
The 'Grid Placement Conflict Handling' section of the specs says:
If the placement contains two spans, remove the one contributed by the end grid-placement property.
So that code, when considered in isolation, is equivalent to:
grid-column-start: span 2;
That works okay if you don't specify a start line for the grid item. But let's say you need to make the item start from the third line… You could set grid-column-start
to 3
, but now you've overridden the previous value of span 2
. What you're really wanting to say is this:
grid-column-start: 3;
grid-column-end: span 2;
The reverse is true if you want to set its position from the right edge of the grid. Then you might say:
grid-column-start: span 2;
grid-column-end: -3;
A utility framework like Tailwind can't possibly know which end you want to position the cell from, so it covers its bases and defines both up front:
grid-column: span 2 / span 2;
Now, you can overwrite either of these properties with an integer (representing position), or you can just leave it as, and the grid-column-end
value is simply ignored.
span 1/ span 1
is simply equal tospan 1
because start and end are equal: If the start line is equal to the end line, remove the end line (w3.org/TR/css-grid-1/#grid-placement-errors) – NestorIf the start line is equal to the end line, remove the end line
. This makes it so much clear :) – Ines