Edit:
Css only method using flexbox to reorder #a and #b in the order you want while they actually are reversed in the html.
http://jsfiddle.net/15j14Ljb/
You can only affect child elements or elements after the hovered element with css :/
You can do it with jQuery (js) though:
var originalBackground;
$("#b").hover(function() {
originalBackground = $("#a").css("background");
$("#a").css("background", "#ccc");
}), function () {
$("#a").css("background", originalBackground);
});
Or pure js:
var originalColor = document.getElementById("a").style.backgroundColor;
document.getElementById("b").onmouseover = function() {
document.getElementById("a").style.backgroundColor = "blue";
}
document.getElementById("b").onmouseleave = function() {
document.getElementById("a").style.backgroundColor = originalColor;
}