What you are attempting to accomplish can't currently be achieved with data attributes as has been said by several people already. While the answer from @Eugene will work, it will add an incredible amount of bloat to your css file and is therefore unreasonable. @benny-neugebauer was correct in saying that it isn't possible with data attributes but he isn't entirely correct in saying that you need javascript to accomplish it. There is a way to achieve it with html and css only...
We need to start by converting your attribute from a data attribute to a css variable.
<a class="wbutton tint" data-tint="rgba(255,0,0,.5)" href="#">This should be red, with an opacity of 0.5</a>
becomes
<a class="wbutton tint" href="#" style="--data-tint:rgba(255,0,0,.5);">This should be red, with an opacity of .5</a>
Next, we need to modify your css slightly. It should also be noted that since you used a comma in your attr()
, where you have color
is where you are supposed to, or can, include a fallback in case your variable is invalid. If you wanted to declare that the attribute value should be a color then you would not use the comma.
.window > .content .wbutton.tint {
border: solid thin attr(data-tint, color);
box-shadow: inset 0 0 50px attr(data-tint, color);
}
becomes
.window > .content .wbutton.tint {
border: solid thin var(--data-tint);
box-shadow: inset 0 0 50px var(--data-tint);
}
You can see it in action below.
.window>.content .wbutton.tint {
border: solid thin var(--data-tint);
box-shadow: inset 0 0 50px var(--data-tint);
}
<div class="window">
<div class="content">
<a class="wbutton tint" href="#" style="--data-tint:rgba(255,0,0,.5);">This should be red, with an opacity of .5</a>
</div>
</div>
Here is an article by Chris Coyier at css-tricks.com that provides more information.