1

I've got a CSS structure problem regarding multiple items with the same contents.

What I want is for there to be two divs, one with a class of right and another with a class of left. They both have several links inside of them with no classes attached to them. What I want is to be able to simply do something like this:

<!DOCTYPE html>
<html>
<head>
<style>
div.left or div.right > a {
    background-color: yellow;
}
</style>
</head>
<body>

<div class="right">
  <a href="google.com">test</a>
</div>

<div class="left">
  <a href="google.com">test2</a>
</div>

</body>
</html>

I know that won't work, but I was wondering if there was an alternative method of doing this.

Tom Doyle
  • 182
  • 3
  • 15

1 Answers1

4

Use like below.

div.left > a, div.right > a {
background-color: yellow;
}
Suresh Ponnukalai
  • 13,820
  • 5
  • 34
  • 54