I want to create a text style similar to a label. Looky here:
I can nearly do it using just: http://jsfiddle.net/STApE/
p{display: inline; background: yellow;}
BUT, I want to add some padding. When I do, things go downhill. Same happens if I add a border: http://jsfiddle.net/JN72d/
Any ideas on a simple way to achieve this effect?
How Do I Highlight Text In CSS? To Highlight text in HTML you have to use an inline element such as the <span> element and apply a specific background style on it. This will create the highlighting effect, which you can tweak in many different ways to create different looks.
To change the color of the highlighted-text, simply target the ::selection selector and then define the color of the background property.
Use a pseudo-selector ( label[required] ) to choose all labels that are required, then add content ( content: "*"; ) after ( ::after ) the element's content. Save this answer.
I was able to achieve it by modifying your DOM structure a bit:
http://jsfiddle.net/Zp2Cm/2/
Wrap each line with a span. Set the span to be block-level. Apply background and padding to span.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With