Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
2019.01.16.adding-content-via-css-attr
<html>
<head>
<style>
.simple:before {
content: attr(message) ", I'm a div with a 'message' attribute";
}
.data-based:before {
content: attr(data-message) ", I'm a div with a 'data-message' attribute";
}
</style>
</head>
<body>
<div class="simple" message="Hello there"></div>
<div class="data-based" data-message="Hello there"></div>
</body>
</html>
<selector>:[before|after] {
content: [attr(<attribute>) | 'plain text']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.