Changing Heading Backgrounds In Posts

Posted in: Newspaper
Post count: 19

I’m looking at changing the background colour of my H2 headings to blue for only posts not pages. I’d also want the text to appear in white as well as centered.

What’s the best way to do this, I presume through CSS? If so, what’s the correct CSS to use for this please?

Thank you

  • This topic was modified 7 years by robben07.
Post count: 20688

Hi,

So you mean the h2 headings that you enter in the post content? You could use the WordPress color settings for that – http://prntscr.com/nqx4hr
But if you already have many posts for which you want to do this, then it would be better with CSS, opposed to manually editing all of them.

Something like this should work – http://prntscr.com/nqx67r

.td-post-content h2 {
background-color: blue;
color: white;
}

The code can be entered in the theme panel custom CSS section, it will apply to all the h2 headings in the post content.

If I misunderstand or you have more questions let me know.
Thanks

Post count: 19

Hi Simion,

Thanks for your reply.

The CSS works fine.

Regarding the WordPress colour settings, I have the Gutenburg editor and I can’t seem to see this option available. I can change the background colour for text blocks but not for headings. Please let me know if this correct?

Kind regards

Post count: 20688

Hi,

It is possible in Gutenberg if you use the classic element, which has color settings I mentioned above
http://prntscr.com/nrekre

But if you use the Gutenberg heading element it is not possible it seems, these would be the only settings the heading element has from what I can find
https://gogutenberg.com/blocks/heading/

Thanks

Post count: 19

Ok, thanks for clarifying.

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.