9

I am looking for a way to enlarge the distance between the text and underline on my pages. i use mainly CSS but i had to use tags as well, basicly my question considers both cases. is there a way to change this spacing? the code is pretty simple:

.title_span {
  font-weight: bold;
  text-decoration: underline;
  color: grey;
}

my other posibility is try somehow use background for the span using 1px picture and repeat against X axis i am looking for cleaner solution.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
antonpuz
  • 3,256
  • 4
  • 25
  • 48

4 Answers4

10

Not without tricks, no. One simple solution is to wrap the text in another span and give that a bottom border.

.title_span {
  font-weight: bold;
  text-decoration: underline;
  color: grey;
}

.underline {
  padding-bottom: 2px;
  border-bottom: grey 1px solid;
}
<span class="underline">
  <span class="title_span">title of something</span>
</span>
Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
0

I'm afraid this isn't possible per se, but what you can do is apply a border-bottom as an alternative to background-image

kaqqao
  • 12,984
  • 10
  • 64
  • 118
SW4
  • 69,876
  • 20
  • 132
  • 137
0

spacing between text and underline its No, but you could go with something like border-bottom: 1px solid #000 and padding-bottom: 3px.

edit: if you want the same color of the "underline" (which in my example is a border), you just leave out the color declaration, i.e. border-bottom-width: 1px and border-bottom-style: solid.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Venu immadi
  • 1,585
  • 11
  • 20
0

If you ever feel that your line is too close, we actually have a text-underline-offset feature that allows you to control the distance between the underline and the text.

body {
  font-family: Verdana;
}

span {
  color: #FF0033;
  font-size: 2rem;
  text-decoration: #FF0033 underline 0.2rem;
  text-decoration-style: double;  /* default is solid */
  text-underline-offset: 1rem;
}
<span>PayPayカード</span>
Penny Liu
  • 15,447
  • 5
  • 79
  • 98