Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 notification with HTML elements inside

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

like image 284
user3655551 Avatar asked Nov 07 '14 10:11

user3655551


1 Answers

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.

like image 155
dakab Avatar answered Oct 26 '22 10:10

dakab