0

I want output as follows I want to like this btw currently I'm using bellow CSS to do this

.text-underline {
    border-bottom: 4px solid #f8f8f8;
    padding: 0 0 2px;
  }

But it applies to whole text are and I want to reduce width of this line

Pandula
  • 45
  • 5

3 Answers3

2

It's very simple using a pseudo element:

.text-underline:after {
  display: block;
  height: 0;
  width: 5%; /* any width of your choice with any units e.g. px, em... */
  border-bottom: 4px solid #ff0000;
  content: "";
}
Arbel
  • 30,599
  • 2
  • 28
  • 29
0

It's possible with pseudo-elements, like this:

span {
  position: relative;
  font-weight: bold;
  font-size: 20px;
}

span::after {
  display: block;
  content: '';
  width: 40px;
  height: 2px;
  background-color: red;
}
<span>Search Options</span>
J4R
  • 1,094
  • 1
  • 11
  • 19
-1

You have selected the entire item and need to use an element like span to isolate the "Search" part of your HTML

<h1> <span class="text-underline"> Search </span> Options </h1>

Try that out