Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use the repeat() notation for repeated grid tracks
Define repeated CSS grid tracks with the repeat() function instead of writing the same track value several times in a row, for example `repeat(3, 1fr)` rather than `1fr 1fr 1fr`. It states the repetition once and is easier to change.
Bad example
| 1 | grid-template-columns: 1fr 1fr 1fr; |
Explanation (EN)
Three identical tracks written out by hand.
Objašnjenje (HR)
Good example
| 1 | grid-template-columns: repeat(3, 1fr); |
Explanation (EN)
repeat() expresses the count once and scales cleanly.
Objašnjenje (HR)
Notes (EN)
Use repeat() whenever two or more consecutive grid tracks share the same size definition, including composite track values like repeat(2, minmax(0, 1fr)). It reads better and a change to the track size or count is made in one place.
Exceptions / Tradeoffs (EN)
Write tracks out individually when they differ, or when there is only one track.