Both methods above require that one of the image dimensions be known, but if you need to allow for arbitrarily-sized images without adjusting CSS, a Javascript function can be used to find the necessary dimension and "turn on" one of the two caption methods. This allows graceful degradation to top-aligned captions when javascript in unavailable or the browser lacks the necessary DOM functions. The image and caption below use the first method, but leave the caption CSS properties "position" and the "left" unspecified. If the function is successful, it sets these properties.