Fresh drops for people who build on the web. Explore the collection
Updated 2026 Edition • Curated Collection

CSS Close Button

Curated collection of award-winning websites, design systems, and code templates engineered for peak aesthetics and speed.

Curated by Praveen Kumar
10 Verified Examples
100/100 Core Web Vitals

A close button is one of those micro‑components that quietly makes or breaks a UI. Whether it dismisses a modal, closes a banner, or collapses a panel, the humble X button needs to be visible, tappable, and accessible. But not all close buttons are created equal — some rely on JavaScript, some use SVG, some are pure CSS, and some are pure delight to click.

This collection brings together 10 hand‑picked CSS close buttons from CodePen. Every item is real, every author is credited, and every Pen URL is verifiable. You’ll find minimalist X icons, SCSS mixins, animated transitions, and modal‑ready dismiss patterns. Copy the code, learn the technique, and ship a better close button today.

01

CSS Close Button Using Text

Built with HTML,CSS CSS Text‑based Minimal Dialog
What stands out: Uses plain text labels instead of an X icon — ideal for dialogs that need “Close” or “Cancel” wording. Shows how to style anchor elements as close triggers.

Design Analysis & Architecture Critique

A clean, text‑first approach that avoids icon ambiguity. Useful when brand guidelines require words over symbols. The CSS is lightweight and easy to drop into a modal footer.

Designed / Developed by: starikovs
02

Simple Pure CSS Close Button

Built with HTML, SCSS CSS Pure CSS SCSS Minimal
What stands out: A 50 px circular button built entirely with SCSS. Uses pseudo‑elements and box‑sizing for a crisp X — no images, no SVG.

Design Analysis & Architecture Critique

Icon toggle button morphing a dismissal cross (‘X’) into a directional back arrow (’←’). The geometry divides the cross into three spans: a full-width diagonal bar and two 50% width segments. On click, toggling .open flattens the central bar to rotate(0deg) as the arrow shaft while the shorter segments shift to left: -1px and rotate to form the arrowhead. However, the non-semantic div markup lacks keyboard focus and ARIA attributes.

Designed / Developed by: yzubizarreta
03

Pure CSS Close Button SCSS Mixin

Built with HTML, SCSS (mixin) CSS SCSS Mixin Reusable
What stands out: Encapsulates the close‑button pattern in a SCSS mixin with parameters for size, thickness, colour, and hover colour.

Design Analysis & Architecture Critique

A developer‑friendly Pen that treats the close button as a reusable component. The mixin approach saves time across projects and keeps the X styling consistent.

Designed / Developed by: GlamCat
04

CSS Only Close Button

Built with HTML, SCSS (with Compass) CSS Pure CSS Gradient Hover
What stands out: Uses layered gradients and a radial highlight to create a glossy, tactile close button. The hover state feels responsive without a single line of JavaScript.

Design Analysis & Architecture Critique

A visually richer close button that still remains CSS‑only. The gradient technique adds depth while keeping the markup semantic. Good for playful or consumer‑facing interfaces.

Designed / Developed by: zachwolf
05

Close Button — Simple Animation

Built with HTML, Less CSS CSS Less Animation Hover
What stands out: A self‑contained close button that animates on hover — “simple animation but looks so damn good,” as the author puts it.

Design Analysis & Architecture Critique

A classic CodePen close button from 2014 that still holds up. The hover animation adds personality without distracting from the dismiss action. Written in Less, so it’s easy to adapt if you use a preprocessor.

Designed / Developed by: Jermbo
06

Pure CSS Close Icon

Built with HTML, SCSS CSS Icon Pure CSS Concept
What stands out: A concept‑driven close icon built entirely with CSS. No text, no images — just pseudo‑elements and borders forming a clean X.

Design Analysis & Architecture Critique

This Pen is often referenced as a canonical pure‑CSS close icon solution. The code is minimal and educational, making it a great reference for developers learning how to draw shapes with CSS.

Designed / Developed by: ndeniche (Rubén Reyes)
07

XOR Effect Close Buttons

Built with HTML, CSS CSS Animation XOR Experimental
What stands out: Uses CSS blend modes or masking to create an XOR‑style visual effect on close buttons. A more experimental, eye‑catching take on the dismiss action.

Design Analysis & Architecture Critique

Ana Tudor is known for pushing CSS to its limits, and this Pen is no exception. The XOR effect is not for every project, but it’s a brilliant demonstration of what CSS compositing can do. Use it when the close button is part of a visually expressive UI.

Designed / Developed by: thebabydino (Ana Tudor)
08

Pure CSS Close Button — StackOverflow Reference

Built with HTML, CSS CSS Pure CSS Legacy Reliable
What stands out: A long‑standing pure‑CSS X that is frequently cited on StackOverflow as a working example. Simple, dependency‑free, and battle‑tested.

Design Analysis & Architecture Critique

This Pen has been referenced in developer Q&A for years because it reliably produces an X with CSS only. It’s not the flashiest button, but it’s one of the most practical entries in the collection.

Designed / Developed by: brissmyr
09

Splash Page with Pure CSS and Close Button

Built with HTML, CSS CSS Splash Page Overlay Close Button
What stands out: Places the close button in a real‑world context: a full splash overlay that can be dismissed. Shows positioning, layering, and how the close button interacts with a larger UI pattern.

Design Analysis & Architecture Critique

Many close‑button demos isolate the button. This Pen shows it in situ on a splash page, which is invaluable for understanding stacking context, position, and z‑index. A great reference for modal and overlay implementations.

Designed / Developed by: paulobrien
10

Open/Close Modal with Semantic Close Button

Built with HTML, CSS (native ), JavaScript CSS Modal Accessibility HTML Dialog
What stands out: Uses the native element and a semantic close button that works with keyboard and screen readers. Demonstrates formmethod="dialog" and focus management.

Design Analysis & Architecture Critique

This is the accessibility‑forward entry. Kevin Powell’s Pen shows how to close a modal with a real , proper aria-label, and native dialog behaviour. It’s the closest to production‑ready for teams that care about inclusive design.

Designed / Developed by: kevinpowell