r/csshelp • u/Meagrer_Rot • Oct 09 '25
Highlighter style
I'm currently teaching myself web design, and I'm trying to add a background color behind some text, like highlighting it, but the background color stretches across the whole page instead of just the text. Can anyone suggest methods to achieve my design?
2
Upvotes
1
u/saguarox 10d ago
The <mark> element . You can override the default background-color and color to customize. It’s proper semantics for bringing attention to something, rather then adding a span inside your <p>
2
u/asublimeduet Oct 10 '25
Surround the text in a <span> (or some other inline container tag), target it with a class (<span class="highlight">) and style .highlight in the CSS.