4 ms·
> the syntax feels awkward, clunky and very specific Yeah, stuff like "2x 100w" looks a bit like magic numbers[1] Also there's potential for confusion in 'x'
by user24 14y ago
> the syntax feels awkward, clunky and very specific
Yeah, stuff like "2x 100w" looks a bit like magic numbers[1]
Also there's potential for confusion in 'x' - does it mean X as in a co-ordinate i.e. width, or zoom? I'd rather see something more verbose like this:
<img src="foo.jpg">
<set src="foo1.jpg" width="100">
<set src="foo2.jpg" density="2">
</img>
Yes it's more wordy to write, but you read code more than you write it so it makes sense to optimise for readability over byte-shaving.
[1] http://catb.org/jargon/html/M/magic-number.html http://catb.org/jargon/html/M/magic-number.html
- othermaciej 14y agoThere are certainly other ways to do it, but this particular way won't work. <img> was historically a "void element" in past versions of HTML, and past browsers, so it can never have child elements.
- annevk 14y agoWe cannot change the way <img> is parsed. See e.g. http://software.hixie.ch/utilities/js/live-dom-viewer/ http://software.hixie.ch/utilities/js/live-dom-viewer/ for the tree you get with that markup. It's not what you expect.
- user24 14y agoFair enough, but that is a technical limitation which is trivial to get around: <setsrc> <img src="foo.jpg"> <set src="foo1.jpg" width="100"> <set src="foo2.jpg" density="2"> </setsrc> Always be wary of allowing arguments that hinge on "it's not technically possible" to shut down good ideas.
- Kilimanjaro 14y agoFTFY <imgset> <img src="foo.jpg"> <img src="foo1.jpg" width="100"> <img src="foo2.jpg" density="2"> </imgset>
- tubes 14y agoNot a good idea. Browsers that do not support imgset would show all three images using that syntax. A new element name like "<set>" would be ignored by them.
- Kilimanjaro 14y agoCSS to the rescue imgset img{display:none;} imgset img:first-child{display:block;} Same with modern HTML5 tags, modernizer or any other tool would handle that for you.
- user24 14y agoNot really, what about browsers that don't support first-child? Backwards compatibility is important.