Here's a code

```
 <a id="link1" href="#" >About</a>
 <a id="link2" href="#">Contact us</a>

```

I want the link1's color to be changed when link2 is hovered.
Is it possible with css?.
['https://Stackoverflow.com/questions/29598991', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4466855/']
Since CSS does not seem to be able to handle this, try JavaScript

```js
window.onload=function() {
  document.getElementById("link2").onmouseover=function() {
    document.getElementById("link1").style.color="red";
  }
  document.getElementById("link2").onmouseout=function() {
    document.getElementById("link1").style.color="blue";
  }
}
```

```html
 <a id="link1" href="#" >About</a>
 <a id="link2" href="#">Contact us</a>
```

Or using siblings

```js
function prevSib(elem) {do { elem = elem.previousSibling;} while ( elem && elem.nodeType !== 1 ); return elem; }

window.onload=function() {
  document.getElementById("link2").onmouseover=function() {
    prevSib(this).style.color="red";
  }
  document.getElementById("link2").onmouseout=function() {
    prevSib(this).style.color="blue";
  }
}
```

```html
<a id="link1" href="#" >About</a>
<a id="link2" href="#">Contact us</a>
```
Use JavaScript to do that( `link1`'s color to be changed when `link2` is hovered ). You need to use html tag attributes like `onmouseover` and `onmouseout`.

Try this code. For changing color of `link1` when `link2` is hovered.

```
<html> 
<head>

<script>

function colorchange(){
 document.getElementById("link1").style.color="red";
}
function colorchange2(){
 document.getElementById("link1").style.color="blue";
}
</script>
</head>
<body>

<a id="link1" href="#" >About</a>
 <a id="link2" onmouseover="colorchange()" onmouseout="colorchange2()" href="#">Contact us</a>

</body>
</html>

```