Say I have a portion of my HTML file that looks like this:
<div data-w="20px">
<p>this is some text this is some text this is some text</p>
</div>
And the <div>
's width should equal data-w
, as shown below.
div { width:[data-w]; }
I know I can use [attribute]
as a selector, but honestly, this is not an alternative:
div[data-w=1px]{ width:1px; }
div[data-w=2px]{ width:1px; }
div[data-w=3px]{ width:1px; }
div[data-w=4px]{ width:1px; }
div[data-w=5px]{ width:1px; }
div[data-w=1px]{ width:1px; }
div[data-w=1px]{ width:1px; }
(...)
Ideas?
Edit
I found a possible duplicate