Tartan comes out of Highland Scottish wool-weaving. The idea that a given pattern belongs to a specific clan is mostly a Victorian-era invention, romanticised and standardised in the 19th century — before that, setts varied freely by region and weaver.
The repeat unit is the "sett" — a sequence of coloured stripes. Weave that same sequence into both the warp and the weft on a twill loom, and wherever two solid-coloured stripes cross, their colours blend into a new one, plus the twill's own faint diagonal grain shows through. That's why tartan reads as both a grid and a soft diagonal texture at once.
A CSS approximation stacks several repeating-linear-gradients of different widths and colours, horizontal and vertical. Following an actual sett's thread count can reproduce a specific historical tartan; for most design purposes, layering three or four stripe widths is already enough to read as "tartan."
When to use
Use for holiday packaging, flannel/outerwear texture, punk and grunge moods. Using a specific clan tartan commercially is worth checking against the Scottish Register of Tartans etiquette.