Practices for Tailwind CSSs
Practices for Tailwind CSS are habits that keep a project accessible, fast and tidy. They include using semantic HTML, visible focus states and sufficient contrast, ordering classes with a formatter plugin, and keeping the production CSS small by avoiding dynamically built class names. They matter as a codebase and team grow.
Stage: Quality · Part of the Tailwind CSS roadmap · Last reviewed 19 November 2026
What to learn in Practices
- Use semantic elements and ARIA correctly instead of styling divs as buttons
- Check focus visibility and colour contrast on interactive components
- Avoid building class names with string concatenation that the scanner cannot see
- Sort classes automatically using the official Prettier plugin
- Inspect the production CSS size and remove unused custom styles
Practices interview questions
Why does bg-${color}-500 fail in Tailwind?
Tailwind finds class names by scanning source files as plain text, so it cannot evaluate a template string at build time and never generates that CSS. Write the complete class names, or map values to full class strings in an object, so the scanner sees them.
Does Tailwind hurt accessibility?
Not by itself. Tailwind only styles elements, so accessibility depends on your markup. Use semantic HTML, keep focus indicators, give enough contrast, support reduced motion and add labels. Utilities such as sr-only and focus-visible exist to help with these.
Where Practices fits in the Tailwind CSS roadmap
Practices belongs to the Quality stage (intermediate level). Maintain it.
Back to the full Tailwind CSS roadmap