This is a CSS selector pattern. Here’s what it means and how it behaves:
- Selector breakdown:
- py-1 — a class (commonly from utility frameworks like Tailwind CSS) that sets vertical padding (padding-top and padding-bottom) to 0.25rem (in Tailwind’s default scale).
- [&>p]:inline — a variant-like selector (used in Tailwind JIT/Arbitrary variants) that targets direct child
elements and applies the inline display property to them.
- Combined behavior:
- Applied to an element, py-1 adds small vertical padding to that element.
- The [&>p]:inline part generates a CSS rule selecting any
that is a direct child (>) of the element and sets display: inline on those
elements.
- Example (Tailwind JIT output equivalent):
- HTML:
First
Nested
- Result:
- The div has padding-top and padding-bottom of 0.25rem.
- The first
(direct child) is display:inline.
- The nested
inside is not affected.
- HTML:
- Use cases:
- Make paragraph children flow inline while keeping vertical padding on the container.
- Useful for controlling child element display without adding extra classes to the children.
- Note:
- This syntax is specific to Tailwind’s arbitrary variants (JIT). In plain CSS you’d write:
.your-class { padding-top: .25rem; padding-bottom: .25rem; }
.your-class > p { display: inline; }
- This syntax is specific to Tailwind’s arbitrary variants (JIT). In plain CSS you’d write:
Leave a Reply