CSS Protips: a curated collection of CSS tips and tricks
CSS Protips is a single-file collection of 29 CSS tricks, from inheriting box-sizing to the newer margin-inline property, each with a code snippet and usually a CodePen demo. It's worth bookmarking as a scannable reference for a specific problem, not a tutorial to read start to finish. It's a cheat sheet, not a course. Most tips still hold up in modern CSS, though a couple carry accessibility caveats the README itself flags.
What CSS Protips Is
CSS Protips is a curated, single-page list of 29 CSS techniques from the AllThingsSmitty GitHub repository, covering box-model resets, selector tricks like :is() and :not(), and layout fixes such as vertical centering and aspect-ratio. Each tip is a short writeup with a code block and, for most entries, a linked CodePen demo. It's licensed CC0-1.0, so every snippet is public domain.
The 29 CSS Techniques
- ✓Box-model fundamentals: a compact CSS reset, inheriting box-sizing from html instead of resetting it everywhere, and the all: unset shorthand instead of resetting properties one by one.
- ✓Selector tricks: :not() to drop the last border in a nav list, negative nth-child to grab the first n items, and :is() to collapse a long list of heading selectors into one rule.
- ✓Layout tips covering flexbox and CSS Grid centering, aspect-ratio for images, margin-inline/margin-block, and table-layout: fixed for equal-width table cells.
- ✓Type and form tips: :root-based fluid font sizing with calc(vw + vh), rem for global sizing paired with em for local sizing, and a 16px minimum on inputs to stop iOS Safari from zooming in on focus.
- ✓Small UX and accessibility fixes — visible :focus outlines on form elements, hiding unmuted autoplay video, styling broken images with a fallback message, and disabling pointer-events on a disabled button.
- ✓A handful of one-off selector tricks: the 'lobotomized owl' (* + *) for consistent vertical rhythm, :empty to hide elements with no content, and a CSS-only slider built from max-height and overflow.
When to Use These Tips
- •Pulling up a quick fix when a nav border, a centered modal, or a broken-image placeholder needs a CSS-only answer instead of writing custom code from scratch.
- •Code review or mentoring — pointing a junior dev at the :not() or :is() tip instead of re-explaining specificity from scratch.
- •Auditing an existing stylesheet for margin-hack workarounds (nth-child chains for gutters) that flexbox's justify-content: space-between replaces outright.
- •Learning a handful of newer CSS properties — aspect-ratio, margin-inline, :is() — that predate most bootcamp curricula but show up in modern codebases.
Strengths
- ✓Every tip ships a working code block, and most link to a live CodePen demo you can fork and poke at immediately.
- ✓Short, single-purpose entries — read one in under a minute instead of scrolling a 2,000-word blog post to find the CSS.
- ✓Licensed CC0-1.0, so you can lift any snippet into a commercial project with zero attribution paperwork.
- ✓Covers current-ish CSS (aspect-ratio, :is(), margin-inline) alongside older workarounds, so it's not stuck in a 2015 time capsule.
- ✓The numbered table of contents links straight to each tip, so it works as a real reference, not just a wall of text.
What CSS Protips Doesn't Cover
- △Two tips (comma-separated lists via ::after, and empty-link attribute selectors) come with the README's own warning that they can break screen readers and copy/paste — you have to read the caveat, not just copy the snippet.
- △Non-English versions often fall out of sync: according to the README, adding a tip requires updating more than a dozen-plus translation files, and warns that the non-English READMEs may not contain every tip listed in the primary version.
- △It's one long scrollable page with no search, filter, or tagging by CSS feature — finding a specific tip means Ctrl+F or scanning the numbered contents list.
- △No dates or CSS-baseline notes attached to individual tips, so nothing tells you whether a given trick is still current best practice or has since been superseded.
Other CSS Learning Resources
Frequently Asked Questions
CSS Protips lists 29 numbered CSS tips and tricks in its README, covering everything from a basic CSS reset and box-sizing inheritance to newer additions like aspect-ratio and margin-inline, with a short code snippet attached to each one.
CSS Protips does include newer CSS features like aspect-ratio, :is(), and margin-inline alongside older tricks, so it isn't frozen in an early-2010s snapshot, though individual tips aren't dated so you can't tell how recently each one was added.
CSS Protips assumes you already know CSS fundamentals — selectors, the box model, flexbox basics — since each tip is a short shortcut or refinement, not an explanation of the underlying concept from scratch.
CSS Protips accepts contributions through the CONTRIBUTING.md guidelines linked in its README; the maintainer notes that adding a new tip means updating it across all the translated versions too, which is why translations can lag.
CSS Protips features :not(), :is(), :root, :empty, :focus, and nth-child among the pseudo-classes it covers, plus attribute selectors on empty links and the universal-plus-adjacent-sibling '* + *' combinator used in the 'lobotomized owl' layout trick.
CSS Protips is licensed CC0-1.0, which places it in the public domain, so every code snippet in the collection is free to copy into a commercial project without attribution or a licensing fee.
Who should try it — and who should skip
Front-end developers who already know CSS basics and want a fast reference for specific problems — centering a div, killing a margin hack, styling a broken image — get the most out of CSS Protips. Beginners still learning selectors or the box model should start with a structured course instead, since the tips assume you already know what box-sizing and flexbox are and just want the shorthand. Anyone maintaining a design system should also cross-check the two accessibility-flagged tips before shipping them.
Related repositories
Want a second opinion on css-protips?
Ask an AI that can read this page — one click and you get its take on css-protips.
