[whatwg] Adding a src attribute to all elements

Tab Atkins Jr. schrieb:
> On Tue, Nov 3, 2009 at 8:21 PM, Michael A. Puls II <shadow2531 at gmail.com> wrote:
>> On Tue, 03 Nov 2009 21:05:26 -0500, Curtiss Grymala <curtiss at ten-321.com>
>> wrote:
>>> For instance, if I create a level 1 header that looks like:
>>> <h1 src="/example.png">This is a header</h1>
>>> The text "This is a header" would be replaced with the image that's
>>> located at /example.png. However, if /example.png returns a 404 error,
>>> the text would be displayed instead.
>> Opera supports this with css extensions.
> 
> This is supported in the CSS specs properly, via the content property.
> 
> *[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>

Received on Wednesday, 4 November 2009 02:03:49 UTC