/    Sign up×
Community /Pin to ProfileBookmark

link hover change parent element style;

So I have an unordered list, with list items containing hyperlink tags

“`
<ul>
<li>
<a href=”#”>Tag</a>
</li>
<ul>
“`

On my LI tag, I have a border bottom set to the background color.

When my link is hovered I want to change the color of it?

How do I change the previous elements style?

“`
ul li a:hover{
text-decoration: none;
color: #Blue;
}

ul li a:hover li{
border-bottom: solid 5px #Green;
}

“`

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 24.2020 — Pending one of the CSS experts here coming up with a clever solution I don't know, would it make any sense to do all the styling on the a element (and just have the li element there for syntax with 0 padding)?
Copy linkTweet thisAlerts:
@abdlimranNov 24.2020 — Hi! You can't use or apply the hover effect on a child to the parent element, it's not supported by the CSS. You can only use the parent to chilled hovering.
Copy linkTweet thisAlerts:
@abdlimranNov 24.2020 — You can do this using JavaScript onmouseover event.
Copy linkTweet thisAlerts:
@sibertNov 24.2020 — https://jsfiddle.net/xg74w2ry/1/
Copy linkTweet thisAlerts:
@VITSUSANov 24.2020 — You are right NogDog there is no sense to do all the styling on the a element.
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...