How to add line through texts in html css

Line is constructed by establishing a border-down on H2 and then provide H2 a small line-height, put the text in a nested period with a non-transparent background goes.

HTML Example :

<h2><span>TEST</span></h2>
<p>test contents</p>

Example CSS :

h2 {
      width:100%;
      text-align:center;
      border-bottom: 1px solid black;
      line-height:0.1em;
      margin:10px 0 20px;
}

h2 span {
        background: #fff;
        padding:0 10px;
}

SEE DEMO   https://jsfiddle.net/Webcodingwordpress/b5sgw0ve/

Comments