2

I have three a tags inside a div all with hrefs

.title {
    text-decoration: none !important;
    color: #000000;        
}

.title:hover{
    color: #f20d20;
}
<div>
    <a class="title" href="google.com">title 1</a>   
    <a class="title" href="google.com">title 2</a>
    <a class="title" href="google.com">title 3</a>  
</div>

I would like it so that if the user hovers over one element all of them change hover color. Im sure this is a simple problem but i cant get it to work.

Sato Takeru
  • 1,092
  • 1
  • 5
  • 16
Wazy
  • 462
  • 4
  • 17

3 Answers3

3

Add Hover to the parent and color to the items:

div:hover title {
  color: #f20d20;
}
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Zakis Raj
  • 31
  • 2
2

You can use div:hover

You cannot select all siblings of an element. You can select titles followed by the hover title with .title ~ .title but for previous titles no way in css.

mrash
  • 883
  • 7
  • 18
-1

Can you please check the below code? Hope it will work for you. Here I have added display:inline-block property to the parent div so that it does not cover the entire block on hover. Also added hover to the parent div and color to the links.

div {
   display:inline-block;
}

.title {
    text-decoration: none !important;
    color: #000000;  
}

div:hover a{
    color: #f20d20;
}
<div>
    <a class="title" href="google.com">title 1</a>   
    <a class="title" href="google.com">title 2</a>
    <a class="title" href="google.com">title 3</a>  
</div>
Yudiz Solutions
  • 4,216
  • 2
  • 7
  • 21