[whatwg] image captions

Quoting David Walbert <dwalbert at learnnc.org>:
> For scripting purposes I have occasionally needed to tie an image and
> its caption explicitly by giving them related IDs that a particular
> javascript function can call (e.g. img id="img1" and p id="img-
> caption"), and it would be helpful in these situations to have a
> standard syntax for that explicit relation. But the availability of
> such syntax should not imply that everyone needs to use it for all
> markup, all the time; I can't see it being useful in ordinary web
> design (to the reader/user, which should ultimately be the point)
> unless there are actions associated with the image and caption.

If the relationship between the image and caption is well defined. For  
example, when the next sibling _element_ of <img> is <p>, <p> is the  
caption of <img> you can easily introduce some DOM attribute on  
HTMLImageElement named caption that gives you back the  
HTMLParagraphElement associated with it.


-- 
Anne van Kesteren
<http://annevankesteren.nl/>

Received on Tuesday, 27 June 2006 06:10:51 UTC