# Edit the color of a child on hover

**URL:** <https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578>\
**Category:** Ask us anything\
**Tags:** css\
**Created:** [December 12, 2022, 1:25pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578 "2022-12-12T13:25:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanmatthieud](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jeanmatthieud](https://community.weweb.io/u/jeanmatthieud)\
**Post date:** [December 12, 2022, 1:26pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/1 "2022-12-12T13:26:00Z")

</div>

Hi,

I have a “large” div, with padding, and contain some text (p) elements.  
I want to change the color of the text, when the div is on “hover” state.  
I tried to add some custom CSS on the DIV, but I don’t know how to select a child element.

Thanks,

JM

---

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/matthieu/32/1288_2.png) [@Matthieu](https://community.weweb.io/u/Matthieu)\
**Post date:** [December 12, 2022, 2:55pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/2 "2022-12-12T14:55:03Z")

</div>

Hey JM,

That’s a very interesting question (and need).  
I’m interested in doing this also: aka CSS parent heritage / default CSS value.  
Maybe we will be able to do this natively soon with the new states coming.

As for now, I would create 2 workflows on the parent element to set bool variable to `true` on `mouse enter` and set the variable to `false` on `mouse leave`event.  
You can then bind the color property of your text to this variable using something like :  
`if(mouse_over,"#FFFFFF","#000000")`.  
If many elements: don’t do a bool variable but store and test the ID of your element.

Not clean but… hope it helps.

Matth-

---

<div class="post-metadata">

**Author:** ![jeanmatthieud](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jeanmatthieud](https://community.weweb.io/u/jeanmatthieud)\
**Post date:** [December 12, 2022, 3:36pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/3 "2022-12-12T15:36:30Z")

</div>

Are you sure that it’s required to use workflows / variables for a so simple task ?  
It should be basic CSS…

---

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/matthieu/32/1288_2.png) [@Matthieu](https://community.weweb.io/u/Matthieu)\
**Post date:** [December 12, 2022, 3:52pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/4 "2022-12-12T15:52:55Z")

</div>

I might very well be wrong. This is my current understanding (but I’m new).  
Maybe people from WeWeb themselves will see your post and will have a different/better solution.  
@Joyce ? @aurelie ?

Have a nice day.

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [December 12, 2022, 4:39pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/5 "2022-12-12T16:39:32Z")

</div>

This is indeed quite complicated at the moment, but will be very easy after the release of the new states (currently in QA).  
I will let you know as soon as this is available 🙂

---

<div class="post-metadata">

**Author:** ![yunus](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/yunus/32/3122_2.png) [@yunus](https://community.weweb.io/u/yunus)\
**Post date:** [May 30, 2023, 6:38pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/6 "2023-05-30T18:38:45Z")

</div>

States don’t control the children as intended with proper HTML structure, if you have a solution to this please let us know.

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [May 30, 2023, 7:43pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/7 "2023-05-30T19:43:33Z")

</div>

The solution is to select hover state of the parent, and activate the option “Apply to children”  
Then on any child you can select the state “parentContainerName:hover” (will be on the list)

---

<div class="post-metadata">

**Author:** ![yunus](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/yunus/32/3122_2.png) [@yunus](https://community.weweb.io/u/yunus)\
**Post date:** [June 1, 2023, 9:53pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/8 "2023-06-01T21:53:38Z")

</div>

Worked nicely, thanks.

---

<div class="post-metadata">

**Author:** ![eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@eric](https://community.weweb.io/u/eric)\
**Post date:** [November 11, 2023, 1:13pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/9 "2023-11-11T13:13:06Z")

</div>

Hello @aurelie  
This topic from May and last year, but now, I wanna use that effect of “parent css”.  
but now, in a div, I cant find where is the “Apply to children”, so, where can I find it?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/eba522bbb640d9aeda3cc1bbd059f0efbd37371b.png)

---

<div class="post-metadata">

**Author:** ![Dominic](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dominic/32/5645_2.png) [@Dominic](https://community.weweb.io/u/Dominic)\
**Post date:** [November 11, 2023, 3:34pm UTC](https://community.weweb.io/t/edit-the-color-of-a-child-on-hover/1578/10 "2023-11-11T15:34:22Z")

</div>

Hello @eric

Just expand State section on the right sidebar 🙂

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/314f5297213ac1fac7926a278601f60a9fc9a768.png)
