6
uyouthe
31d

CSS quick maffs

<button data-unread-count=“10”>Chat</button>

button::after { content: attr(data-unread-count); }

That’s how you do unread messages badge and many things more

Comments
  • 0
    Or... Just <?php print $unreadCount; ?> Within a span you style.
  • -1
    @theMaintainer yes but heavier dom then. You conveniently dropped the implementation to prove your point, an expected move from a php guy
  • 0
    I can set “abc” as unread count though
  • 0
    @010001111 yes, HTML doesn’t have static typing when it comes to printed out values. Some attributes have kind of type checking though
  • 0
    @uyouthe lol I take you're the type of dev who overthinks even the simplest of tasks.
  • 0
    @theMaintainer lol I got product of the day for an html file with 6 lines of js, of course I’m always overthinking and pathologically can’t deliver a simple solution that is just good enough, of course
Add Comment