&

py-1 [&>p]:inline

What this selector does

The utility-like string py-1 [&>p]:inline looks like a Tailwind CSS (or Tailwind-inspired) class combination that applies:

  • py-1: vertical padding of 0.25rem (top and bottom) to the element.
  • [&>p]:inline: a variant using Tailwind’s arbitrary selector/variant feature to target direct child

    elements and set them to display: inline.

Together, they make the parent element have small vertical padding while forcing any immediate paragraph children to render inline instead of as block elements.

When to use it

Use this when you want an element with compact vertical spacing but need its direct

children to flow inline with surrounding content for example:

  • Inline lists of short paragraphs or labels inside a card header.
  • Compact tag/label groups where semantic

    is preferred but block layout is undesirable.

  • Situations where you cannot change HTML markup (must keep

    tags) but need inline display.

Browser/CSS notes

  • The [&>p]:inline part relies on Tailwind’s arbitrary variant support (using the JIT engine). Ensure your Tailwind config and version support arbitrary variants and the notation [&>p].
  • The generated CSS roughly becomes:
    css
    .py-1 { padding-top: .25rem; padding-bottom: .25rem; }.[&>p]:inline > p { display: inline; } /Tailwind transforms selector differently */

    Actual selector emitted by Tailwind will target direct child

    selectors appropriately.

  • If not using Tailwind, you can replicate behavior with plain CSS:
    css
    .compact { padding: .25rem 0; }.compact > p { display: inline; margin: 0; }

Accessibility and semantics

  • Converting paragraphs to inline can affect reading flow and screen-reader interpretation slightly; ensure the content still makes sense semantically.
  • Remove default margins on

    when changing to inline to avoid unexpected spacing.

Example usage (HTML)

html
<div class=“py-1 [&>p]:inline”>  <p>Label A</p>  <p>Label B</p>  <span> — extra text</span></div>

This renders the two paragraphs and the span on the same line with small vertical padding around the container.

Alternatives

  • Use or instead of

    if inline behavior is intended from the start.

  • flex or inline-flex on the parent for more layout control.

Your email address will not be published. Required fields are marked *