user3356128
user3356128

Reputation: 67

Target anchor tag within an anchor with CSS

How can I target with css the anchor tag named #individualProfile that is a child of another a href?

I have this from inspected element, where the tag is appended using append()

image from expect element

Upvotes: 1

Views: 3331

Answers (1)

Maen
Maen

Reputation: 10698

As Paulie_D just mention, you shouldn't have an a wrapped in another a.

Meanwhile, if you can't change the HTML structure, you can try this :

a[href] > a[href="#individualProfile"]{
   ...
}

This targets the first a with an href attribute, then the > select a direct child of it, and then specify the a with the wanted href.

This should anyway be more specific, as there can be a lot of other a with href attributes in your page than the one you want to style.

Here's a reference on MDN of attribute selectors for further informations.

Upvotes: 4

Related Questions