[thelist] Dumb CSS question

Lee Kowalkowski lee.kowalkowski at googlemail.com
Tue Dec 4 03:31:17 CST 2007


On 03/12/2007, Charles <lists07 at wiltgen.net> wrote:
> I think I understand.  I'd need to give every <a> around an <img> a class of
> "icon" then, correct?

Yes.  That's one way of making your selector more specific, you could
classify an ancestor element instead if that's more convenient.

I see in your example you have <p style="text-align: center"> as a
container for these items.  You could always classify that element
instead (perhaps 'figure' or something).

I'm not convinced a single image constitutes a paragraph so you could
use a different element, but I understand you're probably using a
WYSIWYG editor, and an alternative element would probably still need
classifying anyway.

> Is the basic lesson that I can't style image links differently than text
> links with CSS without assigning classes?

Hmm, the basic lesson is you can't style elements based on their
descendants, although it would be cool if there was syntax for that.

There are other ways of increasing specificity, but classifying
elements seems to be unavoidable in practice.

-- 
Lee



More information about the thelist mailing list