mx-auto
for horizontal centering primarily works on elements with `display: block` (or `flex`, `grid`) and a defined width.
Attempting to center an `<span>` with `mx-auto` and `w-1/3`:
Gotcha: `mx-auto` (for horizontal centering) and `w-*` (width utilities) typically do not work as expected on `inline` elements. The span above will likely not be centered by `mx-auto` nor will its width be accurately `1/3` of its container without changing its display property. It flows with other inline content.
(Note: To center inline content, you'd typically use `text-center` on its parent block-level element.)
Now, converting the `<span>` to `display: block`:
Corrected: By adding `block` (or `inline-block` if side-by-side layout is needed with other blocks, though `mx-auto` is less common for `inline-block` horizontal centering), the `span` now behaves like a block-level element. With `block`, `w-1/3`, and `mx-auto`, it is correctly centered.
A `<div>` is `display: block` by default:
As Expected: `div` elements are block-level by default. With a defined width (`w-1/2`) and `mx-auto`, they center perfectly.