HTML - * global attributes are used to store user data (ready to be invoked using CSS and Javascript). * - wildcard, which can be replaced with any subtitles.
In the following snippet, CSS uses the data stored in the data-append
to add text :after
contents of the div, while Javascript uses the data stored in the data-color
attribute to apply color against its background:
var zzz = document.getElementsByTagName("div")[0].getAttribute("data-color"); var yyy = document.getElementsByTagName("div")[1].getAttribute("data-color"); document.getElementsByTagName("div")[0].style.background = zzz; document.getElementsByTagName("div")[1].style.background = yyy;
div::after { content: attr(data-append); }
<div data-append="_SUCCESS_" data-color="lawngreen"></div> <div data-append="_FAILURE_" data-color="tomato"></div>
source share