11

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

dakab
  • 5,379
  • 9
  • 43
  • 67
user3655551
  • 111
  • 1
  • 4
  • 1
    Not enough info . What kind of HTML notification? – Cory Jul 19 '15 at 20:48
  • @Cory I think OP is talking about HTML5 Desktop Notifications. See this.http://www.html5rocks.com/en/tutorials/notifications/quick/. He want to how to format the `title` using html tags. – Shrinivas Shukla Jul 20 '15 at 00:58

1 Answers1

5

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.

dakab
  • 5,379
  • 9
  • 43
  • 67