Website Review
What is CSSplay?
CSSplay is a long-running personal reference site by Stu Nicholls that collects pure-CSS experiments and demonstrations. Its focus is showing what can be built with Cascading Style Sheets alone — the site states that most demonstrations use no JavaScript or other programming languages — and it covers menus, layouts, slideshows, tree menus, shapes and other interface patterns.
Who it is for
- Developers learning CSS who want annotated, copyable examples rather than framework documentation.
- Experienced front-end developers looking for unusual techniques, such as CSS-only slideshows, tree menus and shape effects.
- Anyone who needs a menu, layout or interactive pattern without adding JavaScript.
What you will find
- A large catalogue of demos grouped roughly into menus, demos and layouts.
- Experimental techniques that push CSS features, including newer capabilities such as
:has()-style selectors, container queries and grid-based layouts. - A pragmatic, hand-built style: the examples are intended as teaching material and inspiration, not as a packaged component library.
How it compares to other resources
| Resource type | Strength | Trade-off |
|---|---|---|
| CSSplay | Pure-CSS experiments, unusual patterns, no JavaScript dependency | Personal site; examples may need adaptation and testing in your own project |
| General CSS references such as MDN Web Docs | Authoritative explanations of properties and browser support | Less focused on complete, experimental interface patterns |
| Can I Use | Browser support tables for specific features | Does not show full working examples |
A practical next step
Start with a demo close to what you need — for example, a tree menu or slideshow — then copy the CSS into a test page and check it in your target browsers. Treat the code as a learning reference: simplify it, rename classes and verify accessibility and keyboard behaviour before using it in production. If a demo depends on a very new CSS feature, confirm current browser support with Can I Use and keep a fallback for older browsers.
How can I build a CSS-only dropdown or flyout menu without JavaScript?
Build it as a nested list with a hidden submenu that appears on hover or keyboard focus. On CSSplay, Stu Nicholls describes the site as a collection of experimental CSS demonstrations, and its menu section includes drop/flyout and tree menus built with CSS rather than JavaScript. That approach is the practical starting point: use real links or buttons in your markup, then let CSS control visibility and positioning.
A simple pattern:
<nav>
<ul>
<li><a href="/">Home</a></li>
<li class="has-sub">
<a href="/services/">Services</a>
<ul class="submenu">
<li><a href="/services/design/">Design</a></li>
<li><a href="/services/build/">Build</a></li>
</ul>
</li>
</ul>
</nav>
.submenu {
position: absolute;
display: none;
}
.has-sub:hover .submenu,
.has-sub:focus-within .submenu {
display: block;
}
The trade-offs matter more than the syntax:
- Hover-only menus fail on touch and keyboard. Pair
:hoverwith:focus-withinso keyboard users can reach the submenu. - Positioning needs a containing block. Give the parent
position: relativeand the submenuposition: absolute, or the menu may jump. - Deep nesting gets fragile. One level of flyout is usually enough; multi-level trees need careful spacing and z-index handling.
- No JavaScript means no click-to-toggle on small screens. Many CSS-only menus fall back to a stacked list below a breakpoint.
For a concrete case, imagine a small agency site with five top-level items and two sub-items each. A horizontal bar with hover/focus flyouts is appropriate on desktop, while mobile can show all links expanded in a vertical list. That avoids the common failure where a hover menu is impossible to open on a phone.
Nicholls's stated aim is to help newcomers and show that CSS is more than basic styling, so CSSplay is most useful as a demonstration library: study how each menu is structured, then adapt the technique rather than copying it wholesale. For standards questions such as the correct doctype, the W3C website is the authoritative reference; see W3C. If you want a broader set of layout and menu experiments, CSSplay itself is at CSSplay.
What CSS techniques can create a slideshow that runs automatically using only CSS?
CSS-only slideshows rely on animation timing rather than scripting: you define a keyframe sequence that cycles through each slide's visibility or transform, and the browser repeats it indefinitely. CSSplay's demonstration list includes several examples of this pattern, such as "CSS simplest auto slideshow," "CSS auto/manual slideshow," and "CSS full screen slideshow," all built without JavaScript.
Core approaches
- Keyframe-driven opacity or transform: Each slide occupies the same position; a single
@keyframesrule shifts opacity,translateX, orclip-pathat staggered percentages so slides appear in sequence. The animation loops withanimation-iteration-count: infinite. - Animation-delay staggering: Multiple slides share one keyframe set but start at offset delays, creating a rotation without duplicating timing logic.
- Pseudo-class state for manual control: Radio buttons or
:targetlinks let a visitor override the automatic cycle; CSSplay lists radio tree menus and:target-style demos showing this technique in a navigation context. - Modern selectors: CSSplay's recent demos reference
:if(),sibling-index(), andsibling-count()— newer CSS features that can calculate per-slide timing automatically, reducing hand-written delay values. - Container queries: Labeled "@container (style)" demos suggest slide behavior can respond to a container's state rather than only viewport width.
Trade-offs
| Approach | Strength | Limitation |
|---|---|---|
| Pure keyframe loop | No markup overhead, works everywhere | Hard to pause; timing fixed in CSS |
Radio/checkbox + :checked |
Visitor controls slide | Requires extra inputs; accessibility care needed |
:target links |
Deep-linkable slides | URL changes; back-button behavior can confuse |
Modern selectors (:if(), sibling-index()) |
Less repetitive CSS | Limited browser support at time of writing |
Practical scenario: A photographer wants a hero banner that cycles images every five seconds but pauses when hovered. A keyframe animation with animation-play-state: paused on :hover handles this in a few lines. If they also want clickable dots, radio inputs plus :checked sibling selectors add that without script.
Next step: Open a CSSplay demo closest to your layout — for a full-bleed banner, start from the full-screen slideshow example — and inspect how the keyframe percentages map to slide count. If you need per-slide timing that scales automatically, check whether the sibling-index() demos suit your browser targets before committing. For broader CSS reference material, MDN Web Docs documents @keyframes and animation properties in depth.
How do I make a responsive masonry layout with CSS grid?
CSS Grid gives you two practical routes to a masonry-style layout: a true masonry implementation that relies on newer CSS features, and a JavaScript-free approximation using grid auto-placement. Which you pick depends on how much browser support you need and how strictly you want items to pack.
The idea behind the effect
Masonry means items of different heights fill columns without leaving large vertical gaps. Classic CSS Grid rows are uniform, so items in the same row align to the tallest item. To break that, you either let the browser place items into columns independently, or you fake it by spanning rows.
Two common approaches
| Approach | How it works | Best for | Trade-off |
|---|---|---|---|
| Column-based grid spanning | Define fixed row units, then make each item span enough rows to fit its content | Broad support, predictable | You must estimate or measure item heights; spans are set in code |
| Native masonry-style placement | Items flow into columns in source order, heights vary freely | Fluid, content-driven galleries | Depends on newer CSS support; behaviour varies across engines |
The column-spanning method is the safer default. You set a small row height (for example grid-auto-rows: 10px), give each item grid-row-end: span N, and calculate N from the item's rendered height. That calculation is the fiddly part, and it is why many developers reach for a small script or a ResizeObserver.
The native route is cleaner in markup but is the reason a demonstration like the masonry layout on CSSplay is worth studying: it shows how much can be done with pure CSS and no JavaScript, which matters if you want to avoid dependencies. Treat that as technique inspiration rather than a drop-in production component.
A concrete scenario
Imagine a portfolio page with mixed-height cards: a tall photo, a short caption block, a medium chart. With a plain three-column grid, the short card leaves a gap until the next row starts. With a masonry approach, the short card sits directly under the previous item in its column, and the next item fills the space beside it. The visual result is tighter and more magazine-like.
Decision criteria
- Need to support older browsers? Use the row-spanning approximation.
- Building for modern evergreen browsers only? Try native masonry placement, with a grid fallback.
- Content order matters for accessibility? Check that your columns preserve a sensible reading order, since masonry can reorder items visually.
- Dynamic content (infinite scroll, resizing)? Plan for recalculation, because fixed spans go stale when heights change.
Next step
Prototype with three or four items of clearly different heights, resize the window, and watch where gaps appear. If gaps are acceptable, the simple grid fallback is enough. If not, either add height measurement for spans or adopt a native masonry feature and provide a graceful fallback. For more pure-CSS layout experiments, see CSSplay.
How can I create a tree menu using CSS only?
Build it as a nested list where each branch is a <ul> inside its parent <li>, then use CSS to hide and reveal those branches. CSSplay's own menu demos follow this "just CSS" approach, including tree menus and the "ULTIMATE tree menu" series, with no JavaScript in most demonstrations, so it is a good place to see working patterns before writing your own.
The core pattern
Use :hover for pointer users and :focus-within for keyboard users. A simple starting point:
<nav>
<ul class="tree">
<li><a href="#">Section</a>
<ul>
<li><a href="#">Page one</a></li>
<li><a href="#">Page two</a></li>
</ul>
</li>
</ul>
</nav>
.tree ul { display: none; }
.tree li:hover > ul,
.tree li:focus-within > ul { display: block; }
Indent each level with padding or margin, and add a marker (a ::before triangle or plus/minus) to show that a branch opens.
Decide how branches should behave
| Approach | Best for | Trade-off |
|---|---|---|
:hover only |
Desktop navigation, quick scanning | Keyboard and touch users cannot reliably open branches |
:focus-within |
Accessible menus, keyboard users | Needs visible focus styles; can stay open while focus is inside |
<details>/<summary> |
Content trees, documentation, no CSS trickery | Less control over animation; styling varies by browser |
For a site where people must reach every page by keyboard, combine :hover and :focus-within. For a documentation sidebar, <details> is often the least fragile option. CSSplay has demonstrations of both hover-driven trees and details/summary menus, which is useful for comparing the two.
Practical checks
- Keep the markup as a real nested list: screen readers announce the number of items and the hierarchy.
- Do not rely on colour alone to show the open state; use a rotated marker or an icon change.
- Test with the keyboard: Tab through links and confirm each branch opens and closes predictably.
- If the tree is long, consider a column layout or a collapsible panel rather than a deep flyout that covers content.
A sensible next step is to open CSSplay's menu section, pick the tree-menu demo closest to your structure, and rebuild it with your own labels and colours rather than copying the code wholesale. See CSSplay.
What is the correct DOCTYPE declaration to use for standards-compliant CSS demonstrations?
Use <!DOCTYPE html> for any new standards-compliant demonstration. It is the HTML5 doctype, it is short, and every current browser renders pages in standards mode when it sees it.
CSSplay's own guidance is stricter than "pick one and move on": the page stresses that the doctype must be the first line of your (x)html and points readers to the W3C's list of recommended DTDs. That advice dates from the XHTML era, when the exact public identifier decided whether a browser used quirks mode, almost-standards mode or standards mode. Today the practical answer is simpler, but the underlying rule still holds: a missing or malformed doctype drops you into quirks mode, where box sizing, percentage heights and table rendering behave differently — exactly the kind of inconsistency that ruins a CSS demo.
H3 When the choice still matters
- New demos and pages: use
<!DOCTYPE html>. Nothing above it — no comments, no XML declaration, no blank line. - Maintaining old XHTML pages: keep the existing XHTML 1.0 Strict or Transitional doctype if the markup still validates against it; switching doctypes on an untouched page buys you little.
- Framed or embedded demos: each document needs its own doctype; an iframe does not inherit the parent's.
- Testing quirks deliberately: omit the doctype only in a throwaway file where you actually want to compare quirks-mode behaviour.
If you are unsure whether a page is in standards mode, open the developer console and check document.compatMode. It should report CSS1Compat, not BackCompat.
For deeper background, the W3C's own material is authoritative, and CSSplay remains a useful place to see doctype-clean, JavaScript-free CSS experiments in practice.
User reviews (0)