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?
Looking for a CSS selector.
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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;
}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).
Code: Select all
a img {
}
I can't simply do:
Code: Select all
a {
}
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?
Code: Select all
a { }Is there really no way to separate these links from the others?
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.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).Code: Select all
a { }
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.