Style all anchors except those that contain images, without adding class or id to the image tag?
Posted
by Deca
on Stack Overflow
See other posts from Stack Overflow
or by Deca
Published on 2010-03-08T19:40:28Z
Indexed on
2010/03/08
20:06 UTC
Read the original article
Hit count: 242
With the example below, I need to add padding and background-color properties to the text anchor. I then need to exclude padding and background-color from anchors that contain images.
<p>
<a href="#">this is a text link that needs to be styled</a>
<a href="#"><img src="image/name.jpg" alt="this needs to be excluded from styling" /></a>
</p>
If I have a red background and padding on my text links, I do not want that same red background and padding to appear on my linked images. The images will always be in their own anchors, not mixed with text within the same anchor.
The rub is that I can not add classes or IDs to the img tags - I do not have edit control of that data.
So how can I add CSS attributes to all anchors, while excluding anchors that contain images?
© Stack Overflow or respective owner