Re: Stand-in color before images load

Laurens Holst wrote:
> 
> Anne van Kesteren wrote:
> 
>>> <h1 src="heading1.jpg"><em>Surely</em> this would be cool to have</h1>
>>
>> I assume h1:alt would still match the H1 element if image loading was 
>> somehow prevented.

It wouldn't be necessary, doesn't this
   h1[src] { content: attr(src,url); }
already fallback to the normal content when that's not available?


> Oh, stupid me :). h1:alt would even be nice to render a reddish border 
> or something around the element, to indicate something has failed loading.

I don't think so.  If there are styles that need to be applied to the 
elements content, but not when it's a replaced element, something like 
this would work:

   h1[src] { content: attr(src,url); }
   h1::inside { border: 5px dotted red; background-color:blue;
                color: lime; }

This gives both a fallback background colour, as requested by Barry in 
the initial post, the reddish border Laurens wanted, and whatever else 
you want.

Although that's not possible yet, why is there only ::outside and not 
::inside defined in CSS3 selectors?  However, the same result could be 
achieved by polluting the markup with:
   <h1 src="..."><span>...</span></h1>

> So, let’s say :alt (or rather: :loadfail?)

I don't think a pseudo-class is appropriate for this because this would, 
in a way, be a case of the selectivity of a selector being dependant 
upon other styles being applied or not, which no other selector does and 
nor should they.

-- 
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

Received on Wednesday, 30 March 2005 14:19:09 UTC