h1 {
display: inline-block;
position: relative;
}
h1:after {
content: "";
position: absolute;
height: 1px;
background-color: red;
width: 50%;
left: 50%;
transform: translate(-50%);
}
For fading effect at the edges, replace background-color
with this:
background: linear-gradient(
to right,
transparent,
red 40%,
red 60%,
transparent
);