CSS: "AND" and + operator?

Posted by de.vina on Stack Overflow See other posts from Stack Overflow or by de.vina
Published on 2012-03-20T05:21:08Z Indexed on 2012/03/20 5:29 UTC
Read the original article Hit count: 118

Filed under:
|

I want to put a space after all the headers using CSS. Like this:

if h1 = add a space after
else if h1 + h2 = add a space after also but no space in between

This is my HTML code

<article>
     <h1>Title 1</h1>
...
</article>
<article>
     <h1>Title 1</h1>
     <h2>Title 2</h2>
...
</article>

For the CSS

h1, h2 { padding-bottom: 20px; }

The problem is, there is a space also between h1 and h2. I tried this code below but only those articles with h1 and h2 have a space after.

h1 + h2 { padding-bottom: 20px;}

Is there a way to do this? Or I should just use the h1 + h2 in CSS and add < br > for h1 only?

© Stack Overflow or respective owner

Related posts about css

Related posts about operators