Skip to main content

Adding a line under text is generally done with basic text underline formatting.  However, it doesn’t allow you to add any margin or padding between the text and line.

This can be accomplished with an <hr> element.  That works well, unless you need your <hr> element to match the width of your text above.  This becomes even more difficult on mobile and tablet views in addition to em or % based font sizes.

Below is an example of how to use the <hr> styles as a pseudo element to follow the width of the text above it using.


.hr {
  display: inline-block;
.hr:after {
  content: '';
  display: block;
  border-top: 6px solid blue;
  margin-top: 0.5em;


<link href="//" rel="stylesheet" />
<div class="container">
  <div class="row text-center">
    <h1>Header Example</h1>
  <div class="row text-center">
    <h1 class="hr">Header Example 2</h1>

Leave a Reply