Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add box-sizing: border-box to all HTML elements using TailwindCSS

What's the equivalent for this in TailwindCSS?

* {
  box-sizing: border-box;
}
like image 369
Emmanuel Oloyede Avatar asked Oct 26 '25 05:10

Emmanuel Oloyede


1 Answers

Tailwind already has such stylings in preflight - see compiled stylesheet.

/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
*/

*,
::before,
::after {
  box-sizing: border-box; /* 1 */
}

So there is no need to add it unless you've disabled preflights.

However Tailwind's equivalent class name will be border-box - see here

like image 79
Ihar Aliakseyenka Avatar answered Oct 28 '25 18:10

Ihar Aliakseyenka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!