user3655551
user3655551

Reputation: 111

HTML5 notification with HTML elements inside

How can I insert HTML tags inside the title and body of HTML5 notifications?

Upvotes: 11

Views: 3664

Answers (1)

dakab
dakab

Reputation: 5875

You can easily insert HTML in both title and body:

var notification = new Notification('<title>title</title>',{body:'<b>bold</b> content'});

But there’s no point: it won’t render. In Firefox, it’ll look like this:

desktop notification with visible HTML

The spec says that each of them is just a DOMString, and that means it’s just plain text.

If you care only about Chrome support, you might want to take a look at Rich Notifications. Otherwise, it seems we have to wait for some means to style desktop notifications.

Upvotes: 5

Related Questions