I have div
tag for which a data-type
attribute is associated. I want to apply different styles depending on data-type is set or no.
<div data-type="type1">Hello, World!</div>
Can I check if this attribute data-type
is set or no in css/less ? This question is solved with this.
But, if I apply this data-type
attribute only to the parent div
, can I use this attribute for all the child div
tags as well.
For instance,
<div data-type=`type1`>
<div id="newDiv"> </div>
</div>
In my CSS, I want to apply different styles for #newDiv
depending on whatever type (data-type
) is set to its parent. I don't want to specify the data-type
attribute to the child div
as well. How do we do this in CSS ?