Site logo

Archived topic

Editing header elements for POSTS only

3 replies · Started by Ben on January 28, 2021

Viewing posts 1–4 of 4

Hi Guys,

Is there a way to edit the header elements for posts only?

I want to increase the margin on the header elements which I can do with

h2 {
	margin-top: 40px;
}

But it affects the pages too and I don't want that.

Can this be done?

Thanks

Ben

Hi there,

WordPress adds classes to the body element which can be used to target specific posts types ( amongst other things ). For the single post you can use the single-post class in your CSS selector eg.

.single-post h2 {
    /* styles for the H2 in the single post */
}

Oh yeah!

Sorted it.

Thanks

You're welcome

This archived topic is closed to new replies.