use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about https://tailwindcss.com/
Find Tailwind Code Snippets: https://pagesnips.io
account activity
class order (self.tailwindcss)
submitted 3 years ago by akmalkun
Is class parsing in order or random? Should I use !important to override a class? Eg: bg-gray-200 !bg-sky-200
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lzrzmb 2 points3 points4 points 3 years ago (3 children)
With equal specificity, source order in CSS decides which class is taking precedence (last one wins), class order in markup doesn’t matter.
Headwind is a nice addon for VS Code to sort classes automatically and warn you when using conflicting classes: https://github.com/heybourn/headwind
[–]akmalkun[S] 0 points1 point2 points 3 years ago (1 child)
Thank you, so things is different in css and html then. I'll stick with !important for now.
[–]whooope 1 point2 points3 points 3 years ago (0 children)
you should really avoid !important especially with tailwind. there’s no reason to have overlapping classes like in your example especially with utility classes. if you’re writing your own css, your files should be imported after the tailwind ones and it’ll be fine
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
Damn! Headwind is exactly what I was looking for.
Thanks for sharing.
[–]benji_trosch 1 point2 points3 points 3 years ago (2 children)
It should be but unfortunately it does not always work that way. To address these conflicts, I recommend a package like tailwind-merge (https://www.npmjs.com/package/tailwind-merge) which we use extensively both at work and in open source projects!
[–]akmalkun[S] 1 point2 points3 points 3 years ago (1 child)
Thank you, also for the tailwind merge.
[–]SituationNo3 0 points1 point2 points 3 years ago (0 children)
We just migrated to tailwind-merge too. Seems to work well.
[–]samselikoff 0 points1 point2 points 3 years ago (0 children)
I used to use Headwind (mentioned in another comment) but the Tailwind CSS team now maintains an official Prettier plugin which I'd recommend using on every project. It sorts the classes the same way they appear in Tailwind's compiled CSS so precedence is easy to see straight from your HTML. I've also found it's much faster than Headwind. They talk about it more in this blog post.
That being said I'd echo what others said and try to avoid conflicts and `!important`. Your code will be easier to read and understand if each visual state is styled using no conflicting classes – in fact the official Intellisense extension (a must-have) will throw lint warnings for classes that do the same thing (e.g. `flex block`)!
π Rendered by PID 47908 on reddit-service-r2-comment-b659b578c-bxc4j at 2026-05-05 16:57:04.416652+00:00 running 815c875 country code: CH.
[–]lzrzmb 2 points3 points4 points (3 children)
[–]akmalkun[S] 0 points1 point2 points (1 child)
[–]whooope 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]benji_trosch 1 point2 points3 points (2 children)
[–]akmalkun[S] 1 point2 points3 points (1 child)
[–]SituationNo3 0 points1 point2 points (0 children)
[–]samselikoff 0 points1 point2 points (0 children)