Comments that drive the build

Wikis are a common place to find unusual CSS, and Wikipedia's Common.css contains a good example:

.mw-collapsible-leftside-toggle .mw-collapsible-toggle {
  /* @noflip */
  float: left;
  /* @noflip */
  text-align: left;
}

The @noflip marker is an instruction embedded in a comment. Colloquially a "CSS decorator," it remains just a CSS comment until a processor reads it — without that step it has no effect. The likely consumer is a right-to-left build that rewrites float: left to float: right and text-align: left to text-align: right.

Where the directive comes from

The /* @noflip */ syntax traces back to CSSJanus.

The repo points to Wikimedia, so Wikipedia's usage is accounted for. The approach has since spread: there is a styled-components plugin, a Sublime Text plugin, and Salesforce used it in its design system.

A separate effort, Twitter's archived css-flip, handled the same problem. Its README lists the properties that can require flipping: background-position, background-position-x, border-bottom-left-radius, border-bottom-right-radius, border-color, border-left, border-left-color, border-left-style, border-left-width, border-radius, border-right, border-right-color, border-right-style, border-right-width, border-style, border-top-left-radius, border-top-right-radius, border-width, box-shadow, clear, direction, float, left, margin, margin-left, margin-right, padding, padding-left, padding-right, right, text-align, transition, transition-property. A PostCSS equivalent, postcss-rtl, also exists but has been deprecated by its owner.

Native alternatives to flipping

A build step isn't always needed. text-align: start is supported natively and removes the dependency on CSS processing and alternate stylesheets. float has no logical equivalent; rebuilding the layout, with grid for instance, may make flipping unnecessary, though float's ability to wrap text around an element is hard to reproduce with a simple substitute.

Common processor directives

Treating these markers broadly as "CSS comments carrying processor directives," the most frequently used one is arguably:

/* prettier-ignore */
.cool {
  linear-gradient(
    to left,
    pink
    pink 20%
    red  20%
    red
  )
}

This keeps Prettier from reformatting a block of CSS that was hand-formatted for readability, provided the comment sits on the line directly above it.