You’re asking about the CSS selector-like pattern py-1 [&>p]:inline. This is a utility/class pattern used in Tailwind CSS (or Tailwind-style utility libraries) combining a spacing utility with a variant that targets direct child
elements. Explanation:
- py-1 — Tailwind utility that applies padding-top: 0.25rem and padding-bottom: 0.25rem (assuming default config; 1 → 0.25rem).
- [&>p]:inline — A “selector variant” using Tailwind’s arbitrary variants syntax. It compiles to a rule that applies when the element’s direct child
pmatches; specifically it targets the current element but only when its direct childpis styled as inline, or more precisely it generates a selector like:
.your-class[&>p]:inline { display: inline; }
In Tailwind v3 arbitrary variants,[&>p]:inlinemeans “apply theinlineutility (display: inline) to the element when the selector&>pmatches”, where&is the element itself and>pis a direct child paragraph selector. Practically this produces CSS equivalent to:
.py-1:inline > p { display: inline; }
(Exact emitted selector can vary; the intended effect is to set the direct childto display:inline.)
Putting them together on an element like:
Text
- The div gets vertical padding of 0.25rem.
- The direct child
is set to display:inline due to the arbitrary variant.
Notes:
- Make sure your Tailwind config allows arbitrary variants (Tailwind v3+).
- If you want to target all descendant p (not only direct children), use
[&_p]:inlineor[&:where(p)]:inlinepatterns depending on desired specificity. - For more predictable output you can also write a custom plugin or use
> p:inlineif using a plugin that provides child variants.
Leave a Reply