[whatwg] Adding a src attribute to all elements

Michael A. Puls II shadow2531 at gmail.com
Tue Nov 3 20:21:35 PST 2009


On Tue, 03 Nov 2009 21:05:26 -0500, Curtiss Grymala <curtiss at ten-321.com>  
wrote:

> I would like to propose that a src attribute be added to the spec for
> all HTML elements. The content of the file referenced in the src
> attribute would then replace the contents of the element that contains
> the src attribute. The src attribute would then be interpreted
> differently, depending on the type of file referenced in that src
> attribute.
>
> 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.

For example:

<!DOCTYPE html>
<style>
*[src] {
     -o-replace: attr(src);
     width: attr(width);
     height: attr(height);
     display: inline-block;
     border: 1px solid black;
}
*[href] {
     -o-link: attr(href);
     -o-link-source: current;
     display: inline;
     text-decoration: underline;
     color: blue;
}
/* in XML */
image_link[src] {
     -o-link: attr(src) !important;
     -o-link-source: current;
     -o-replace: attr(src);
     display: inline-block;
     border: 1px solid blue;
     text-decoration: underline;
     color: blue;
}
</style>
<h1 src="http://www.google.com/images/logo.gif" width="300"  
height="150">fallback</h1>
<div href="http://hardocp.com/">test</a>
<image_link  
src="http://www.google.com/images/logo.gif">fallback</image_link>

However, -o-replace seems broken, -o-link doesn't always work right,  
attr() doesn't always work right, you can't specify the type/unit of what  
attr() returns (although I think there's a spec for that that no vendor  
follows) and using -o-link with -o-replace probably wouldn't work if  
-o-replace worked right. You can try in Opera 8.x maybe. It might work  
better there.

So, the support is all broken and limited. However, I've always loved the  
idea of it and even like that it's done via CSS. Whether it's more  
semantic to use <img> inside something and <a> around something or not  
doesn't really matter to me.

So, I think the end result of having all elements support @src and @href  
(not necessarily with css like above) would be cool. Yet, vendor devs have  
said that it'd be a pain and or annoying to implement, so...

I don't feel super strongly about it though. I just think it'd be  
nice/cool.

-- 
Michael



More information about the whatwg mailing list