I’m trying to style my H2 on a WordPress website
I use custom CSS to style my H2 with a green background and a line above text.
I would like to remove background (I know how to do it) add a red blank space before text, how can I do?
This is what I have and the CSS
h2 {
background-color: #e7f9f9 !important;
border-top: 1px solid #01c4c4 !important;
padding: 6px
}
and this is what I’m trying to have without using an image file before (for performance)
I tried by myself, but it doesn’t work
h2 {
before: " ";
color: #ff6b26;
border-top: 1px solid #01c4c4 !important;
padding: 6px
}
2
Answers
I tried this and finally works:
Border on top and a colored space before using "border-left". It's simpler and effective! Thank you
You can use the content property to attach it to the non-breaking space but I don’t think this is the right solution. you can nest your H2 inside a div that has the color you would like. then position the H2 with a bit of left padding, a white background & a z-index higher up.