Agyan
adda
Run
Reset
Copy
CSS Tutorial › CSS Position › Badge with absolute position
Back to tutorial
Code
Edit, then press Run or Ctrl+Enter
<style> .card { position: relative; width: 220px; padding: 30px 16px 16px; border: 1px solid #ccc; border-radius: 8px; } .badge { position: absolute; top: 8px; right: 8px; background: crimson; color: white; font-size: 12px; padding: 3px 8px; border-radius: 12px; } .sticky { position: sticky; top: 0; background: #1f386b; color: white; padding: 8px; } </style> <div class="sticky">Sticky header</div> <div class="card"> <span class="badge">NEW</span> CSS Course card </div>
Result