I was having a look at the tailwind-merge and realized that because of the CSS cascade some tailwind classes cannot be overridden once applied.
example: tailwind playground
<div class="grid h-screen place-content-center bg-red-100">
<div class="w-80 bg-red-300 py-8 px-8 p-2">Content</div>
</div>
The p-2 class cannot override the py-8 px-8 classes, no matter in what order we put them, and the same happens with this example
<div class="grid h-screen place-content-center bg-red-100">
<div class="w-80 bg-red-300 px-8 px-20">Content</div>
</div>
I went thru the CSS Cascade documentation at mdn but I still cannot quite get it.
Can anybody explain it to me?
Thanks to @CBroe comment, I realized it all depends on the order in which tailwind classes appears in the generated CSS.
For this example
tailwind generated these classes, in the following order:
So even though
p-2 px-20appears last in<div class="w-80 bg-red-300 py-8 px-8 p-2 px-20">Content</div>, in the CSS file the last ones arepx-8andpy-8, which overrides them.