Imagine having a snippet of code in your HTML file that looks like this:
<div data-v="20px">
<p>this text repeats itself over and over again</p>
</div>
The width of the <div>
should match the value of data-v
, as seen below.
div { width:[data-v]; }
Although using [attribute]
as a selector is an option, it's not the most practical approach:
div[data-v=1px]{ width:1px; }
div[data-v=2px]{ width:1px; }
div[data-v=3px]{ width:1px; }
div[data-v=4px]{ width:1px; }
div[data-v=5px]{ width:1px; }
div[data-v=1px]{ width:1px; }
div[data-v=1px]{ width:1px; }
(...)
Any suggestions for improvement?
Edit
I stumbled upon a potential solution to this issue on Stack Overflow