W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2009

[whatwg] Adding a src attribute to all elements

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 4 Nov 2009 07:58:47 -0800
Message-ID: <dd0fbad0911040758o551dc660j615d193aabace668@mail.gmail.com>
On Wed, Nov 4, 2009 at 2:03 AM, Markus Ernst <derernst at gmx.ch> 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
Received on Wednesday, 4 November 2009 07:58:47 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:18 UTC