Like youtag's answer, my solution uses pseudo-elements, but my underscore only handles the length of the text and can be wrapped over several lines (with underscores running under each line of text).
Basically, I manually close the ends of an elementβs border with circles of pseudo-elements before and after the element:
h1 a { text-decoration: none; position: relative; border-bottom: 15px solid; padding-bottom:3px; } h1 a:hover, h1 a:focus { border-bottom: 15px solid #eb6d32; } h1 a:before, h1 a:after { content: ''; height: 15px; width: 15px; background-color: currentColor; border-radius: 15px; position: relative; display: inline-block; vertical-align: text-bottom; margin-bottom: -18px; } h1 a:before { left: .2ex; margin-left: -.4ex; } h1 a:after { margin-right: -.4ex; right: .2ex; }
I use left and right for pseudo-elements, so the ends don't go too far beyond the text.
See my codepen .
notGettingStabbed
source share