The `div` below has `mx-auto` but no specific `w-*` or `max-w-*` class. By default, block elements like `div` take up the full available width of their parent. While `mx-auto` sets left and right margins to 'auto', if the element is already full-width, there's no space to distribute, so it won't appear centered.
Key: `mx-auto` needs a defined width on a block-level element to have a centering effect.
This `div` has both `mx-auto` and a defined width (`w-3/4`). Now it centers as expected.
The ` ` element below is `display: inline` by default. `mx-auto` does not center `inline` elements because they flow with content and don't have their own "block" boundaries that margins can adjust for centering in the same way as block elements.
To center an element like a `span` using `mx-auto`: You must change its display property to `block` (or `inline-block` if appropriate, though `mx-auto` for centering usually implies `display:block`) AND give it a defined width.
Example of fixing the inline `span`:
Alternatively, to center inline content (like text or an inline `span`) *within* its parent block element, use `text-center` on the parent.