How to remove unnecessary top margin from the first element of the post content

So we have a post content with headers, paragraphs, sorted lists and so on.

A good habit is to leave more space above headings than below them (text scanning and readability).

We set “margin: 32px 0 24px 0;” for headings and “margin: 0 0 24px 0;” for paragraphs. The problem occurs when we start a post with a heading.

A quick solution for having “margin: 0” on the first header in a post is the “first-child” selector. Set the following code:

.lifestyle-single-content .article h2:first-child { 
margin-top: 0;
}

How to Remove Unnecessary Top Margin from First Element in Post Content

and tagged