I\'m trying to produce a highlighted text effect with a bit of padding, but the padding is only applied to the beginning and end, not new lines.
#highlight {
Try setting the display on your span to inline-block:
#highlight {
background: rgba(255, 230, 0, 0.5);
padding: 3px 5px;
margin: -3px -5px;
line-height: 1.7;
border-radius: 3px;
display:inline-block;
}
jsFiddle example
Solution is this CSS:
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
display: inline;
https://css-tricks.com/almanac/properties/b/box-decoration-break/
You need to set the display to inline-block
or block
.
#highlight {
display: inline-block;
/* ... */
}
If you're not limited to a specific HTML standard, you could take a look at the <mark>
tag, which was introduced with HTML5. This site gives you a quick overlook.
Hope it helps!
In case anyone is still looking for an answer:
p {
box-shadow: 0px 0px 0px 5px yellow;
display: inline;
line-height: 2;
margin: -5px -5px;
background-color: yellow;
border-radius: 1px;
}
See jsfiddle here.