Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a horizontal line in between texts in HTML

Tags:

html

css

I want to add a horizontal line in HTML between texts like shown in this screenshot. From this code, I get a line but not centered between the texts. How can I achieve this?

What I need is something like: Publication---------------------Method.

My code:

.horizontal{
    display: inline-block;
    width: 100px;
}
<div class="col-sm-4">
    <h4>Publication <hr class="horizontal"/>Method</h4>
</div
like image 723
user3736334 Avatar asked Oct 19 '25 21:10

user3736334


1 Answers

You can set flex rules for the h4 tag. Aligns the center rule align-items: center. This example good aligns your line to the center of the words.

.col-sm-4 h4 {
    display: inline-flex;
    align-items: center;
}

.horizontal{
    /*display: inline-block;*/
    width: 100px;
    margin: 0;
}
<div class="col-sm-4">
    <h4>Publication <hr class="horizontal"/>Method</h4>
</div
like image 164
s.kuznetsov Avatar answered Oct 21 '25 12:10

s.kuznetsov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!