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.

5
  • Do you want to accomplish to style both hyperlinks in one css-statement? Commented Aug 27, 2014 at 11:52
  • div.left or div.right > a { to div.left > a,div.right > a { Commented Aug 27, 2014 at 11:54
  • sorry, didnt see already answer posted. Commented Aug 27, 2014 at 11:55
  • You might also want to take a look at: stackoverflow.com/questions/25285518/… Commented Aug 27, 2014 at 13:26
  • See this link stackoverflow.com/questions/15676961/… Commented Aug 27, 2014 at 14:48

1 Answer 1

4

Use like below.

div.left > a, div.right > a {
background-color: yellow;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.