Inside ::before/::after, content: attr(data-label) prints the value of an attribute. Combine static strings and attr() to build tooltips, badges, or print-friendly link URLs. It keeps the label in the HTML and the presentation in CSS.
Inside ::before/::after, content: attr(data-label) prints the value of an attribute. Combine static strings and attr() to build tooltips, badges, or print-friendly link URLs. It keeps the label in the HTML and the presentation in CSS.
<!doctype html><html><head><meta charset="utf-8">
<style>.chip::after{content:" · " attr(data-count);color:#8aff9d}</style></head><body style="background:#06040d;color:#e6e0ff;padding:20px"><span class="chip" data-count="12">messages</span></body></html>▶ Open the interactive comic issue