Page 1 of 1
Looking for a CSS selector.
Posted: Sat Dec 30, 2006 9:55 pm
by JellyFish
I have a image wraped around an ancor and I need a way to select the ancor not the img. Ids, names and classes aren't exceptable.
How would I do this with CSS?
Posted: Sat Dec 30, 2006 10:55 pm
by feyd
Unless something has changed, images aren't containers. Maybe you mean you have an image inside an anchor?
Code: Select all
a img
{
border-left: 2px orange;
}
Posted: Sun Dec 31, 2006 8:18 pm
by JellyFish
I do have an image inside an anchor. But I want to select the anchor not the image. So doing:
would select the image element and all the code within the brackets only effect the img, not the anchor, if I'm correct. I want to select the anchor. So is there a parent selector of some-kind in css?
I can't simply do:
'Cause that would select EVERY anchor. Nether could I use class or ID selectors, it's just not an option (Don't ask why).
Posted: Mon Jan 01, 2007 2:44 am
by matthijs
Using
is really the only way. As far as I know, there is no "parent"-selector in css (or it's in the css4 specs somewere

). Then to target some other a elements, you have to have some class, id or use a descendant selector to target them.
Is there really no way to separate these links from the others?
Posted: Mon Jan 01, 2007 4:41 am
by onion2k
JellyFish wrote:I can't simply do:
'Cause that would select EVERY anchor. Nether could I use class or ID selectors, it's just not an option (Don't ask why).
The only ways to select an individual element are through either a class or an ID*. If those aren't options then you're stuffed.
Could you wrap the anchor in another element like a span, and give that an ID?
* Technically you could traverse the DOM tree and pick the 10th anchor on the page, and change it's style with JS, but that would be horrible and rubbish.