CSS selectors (H1 - H6 applying after p)

1

I'm in Doubt to apply some effects in css. I tried with the following css selectors:

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
    margin: 0 0 0.75em 0;
}

h1~p, h2~p, h3~p, h4~p, h5~p, h6~p {
    margin: 0 0 0.75em 0;
}

h1>p, h2>p, h3>p, h4>p, h5>p, h6>p {
    margin: 0 0 0.75em 0;
}

h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
    margin: 0 0 0.75em 0;
}

The idea is that after typing TAG <h6></h6> apply a space to type TAG <p></p> , within a text structure <div></div> for example;

Because I already use the space between the TAG's <p></p> and only need to <h1><h6> .

    
asked by anonymous 12.12.2015 / 17:06

1 answer

1

I think there was a mistake, the attributes inside the selector will be applied in the paragraph and not in h1 ~ h6, so instead of the bottom margin, the correct one would be margin top:

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
    margin: 0.75em 0 0 0;
}

Or, to get clearer:

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
    margin-top: 0.75em;
}

Combinator documentation: here .

    
12.12.2015 / 18:39