Skip to content

Instantly share code, notes, and snippets.

@weirdpattern
Created January 16, 2019 18:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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