CSS selector for image captions
My recommendation would be to not worry about the performance (see: http://www.kendoui.com/blogs/teamblog/posts/12-09-28/css_tip_star_selector_not_that_bad.aspx for actual tests).

If you're still not convinced that it's not as bad as everyone makes it out to be, then your only real option is to modify the contents of &lt;random-element /&gt;.

&lt;div class="media"&gt;
    &lt;div class="img"&gt;
        &lt;img src="an-image.jpg"&gt;
    &lt;/div&gt;
    &lt;random-element&gt;&lt;div id="foo"&gt;content is here&lt;/div&gt;&lt;/random-element&gt;
&lt;/div&gt;


Which allows your CSS to be:

.img + #foo { ... }


Or just

#foo { ... }