Re: The picture element: complexity

On 12 September 2013 10:50, Simon Pieters <simonp@opera.com> wrote:

> On Thu, 12 Sep 2013 16:43:23 +0200, Reinier Kaper <rp.kaper@gmail.com>
> wrote:
>
>  If I may pitch in on this discussion from a front-ender's perspective: I
>> don't see why we would ever want to have media-queries in our markup,
>> isn't
>> the separation of HTML and CSS one of the goals?
>>
>> I get this is an edge case, as it concerns serving images, which is
>> technically not CSS related, but the media queries are.
>>
>
> Media queries are used in CSS, but that doesn't mean that media queries
> can't be used outside of CSS.


No, of course not, but the issue here is the dependency of the mark-up and
the CSS, this should be avoided if possible (which I think it is).


>
>
>  Why can't we do something like <img src="some-lowres.jpg,
>> somewhat-higher-res.jpg, very-high-res.jpg" > and then use CSS selectors
>> to
>> decide which src to apply?
>> Very rough example:
>> @media (min-width: 18em) {
>>   img {
>>     src: 1 // This would be an index based number and if not found,
>> default
>> to 0
>>   }
>> }
>>
>
> Because browsers want to start downloading the correct image before
> stylesheets have been downloaded and parsed.


That's why I proposed that browser download only the first source file by
default. This will create extra overhead for when the CSS has been parsed
(and an alternative source needs to be downloaded) of course, which might
be an issue, but at least there's no tie-in between mark-up and CSS and
there will always be an image to display.


>
>
> --
> Simon Pieters
> Opera Software
>

Received on Thursday, 12 September 2013 15:35:34 UTC