On Wed, Nov 4, 2009 at 2:03 AM, Markus Ernst <[email protected]> wrote: > Tab Atkins Jr. schrieb: >> *[src] { >> content: attr(src,url); >> } > > If I understand things correctly, your example seems a little bit confusing > to me. The *[src] selector selects elements with a src attribute specified, > which does not apply to <h1> (if valid HTML5). Maybe abusing another > attribute could work then? (I apologize if the example is stupid - I spent > some time studying CSS3 now, but am not really familiar with the > recommendations yet.) > > h1 { > content: attr(title,url); > } > > And the HTML: > <h1 title="pix/aheadline.gif">A headline</h1> > > Looks quite ugly, if it would work at all. To match Curtiss' suggestion with > CSS you would possibly rather use the style attribute, something like: > > <h1 style="content: url(pix/aheadline.gif)">A headline</h1>
Yes, it's using the invalid @src attribute, simply because that's what was asked for by the OP. Using a valid attribute like @title, or better yet a new attribute like @data-my-src suggested by Puls, would work equally well. CSS just doesn't care about HTML's attribute validity requirements. ~TJ
