On elements I can specify the data attributes as, e.g.
<div data-widget-type="MyWidgetType1" data-property1="20" data-property2="test">
...
</div>
I want to capture these in a class e.g.
.MyClass1 {
data-widget-type:"MyWidgetType1";
data-property1:"20";
data-property2:"test";
}
<div class="MyClass1">
...
</div>
Is there a way to specify data attribute values in CSS?
No, there is no such functionality even for default attributes (like you can't set name attribute via CSS). But you can select these custom attributes:
.MyClass1[data-widget-type="MyWidgetType1"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With