[whatwg] responsive images srcalt proposal

Garrett Smith dhtmlkitchen at gmail.com
Sun Dec 15 15:19:38 PST 2013


On 12/11/13, Fred Andrews <fredandw at live.com> wrote:
> The problem with a prescriptive standard for pre-loading images is that it
> might be abused by content authors for other purposes.  I would like to see
> UAs able to implement a wide range of image loading strategies using the
> available information, including ignoring any pre-loading hints, and this
> might be necessary for reloading from a cache.
>
> I am open to other ways to specify the available images, and there have been
> many proposals.
>
A src property in css:

@media only screen and (max-width: 500px) {
  #main-pic {
    src: url("/img/main-100.png");
  }
}

<img src="main.jpg" alt="San Diego Zoo">

Unsupported browsers use the HTML src attribute.

Newer browsers download the src only for the most specific matching
CSS for that replaced element and img.src is the img.usedSrc are the
images source that are applied, img.getAttribute("src") is the HTML
attribute.
-- 
Garrett
@xkit
ChordCycles.com
garretts.github.io



More information about the whatwg mailing list