About this snippet

Add a "Popular" or "Sale" label to your cards with this pure CSS corner ribbon. By using absolute positioning and rotation, we create a clean diagonal banner without needing complex SVG shapes.

Size
1.0 KB
Uses
HTML, CSS
Loads
Nothing external
Views
489

Collections

<div class="card">
  <div class="ribbon">POPULAR</div>
  <div class="content">
    <h3>Premium Plan</h3>
    <p>Get access to all features.</p>
  </div>
</div>
* { box-sizing: border-box; }
body {
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #f1f5f9;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card {
  position: relative;
  width: 300px;
  height: 200px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  overflow: hidden; /* Essential to clip ribbon */
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.ribbon {
  position: absolute;
  top: 20px;
  right: -35px;
  background: #ef4444;
  color: white;
  width: 120px;
  padding: 3px 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  transform: rotate(45deg);
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 10;
}

.content { padding: 20px; }
h3 { margin: 0 0 10px; color: #1e293b; }
p { margin: 0; color: #64748b; }
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save