title_body: css - select only when followed by specific element I have a specific problem in which I need to remove the margin-bottom of every Element that has a class only when followed by the same element with the same class. 
  So p.1 has a margin-bottom:1em to give space to any other element that comes after it. But if p.1 is followed by another p.1 the margin-bottom should be 0. The thing is, I can't just give p.text a margin-top because of reasons I don't really want to elaborate.
  
  &lt;p class="text"&gt;text&lt;/p&gt;
  &lt;p class="1"&gt;___&lt;/p&gt;
  &lt;p class="1"&gt;___&lt;/p&gt;
  &lt;p class="1"&gt;___&lt;/p&gt;
  &lt;p class="text"&gt;text&lt;/p&gt;
  
  
  So in this exhample the first and second p class="1" need to be selected. I tried p.1 + p.1 but this only selects the second and third because it selects the sibling preceded by another one and not the sibling that is followed by one. Is this understandable?
  
  Is there any way to do that in EPUB2?
upvoted_answer: As you've discovered, the challenges here are that:
  
  
  in CSS, it's not possible to select a parent or ancestor element by its child; the browser applies CSS 'downwards' only; and
  you can't know what CSS properties and selectors EPUB2-capable readers will actually support.
  
  
  If I've understood your needs correctly, here are three possible options you could try. For readability I've renamed your 1 class as line.
  
  Option 1
  
  .line {
    margin: 0;
  }
  .line + .text {
    margin-top: 1em;
  }
  
  
  Option 2
  
  .text + .line {
    margin: 0;
  }
  .line + .line {
    margin: 0;
  }
  
  
  Option 3
  
  * + .line {
    margin: 0;
  }
  
  
  I've created a pen here to demo these: https://codepen.io/arthurattwell/pen/NQKRrp Just comment out/uncomment the options in the CSS to see how they behave there. You'd need to test in some older EPUB2 readers to see what really works. As @idiotprogrammer explains, support for the adjacent sibling selector (+) is very unpredictable. As I see it, users whose readers support it get your ideal spacing, and those that don't can still read the content at least.