Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html><html>
<head>
<meta charset=utf-8 />
<title>Horizontal Line Behind a Heading with CSS</title>
</head>
<body>
  
<div class="main-container">
    <h1>
      <span id="left"> </span>
      <span id="center">Hello World</span>
      <span id="right"> </span>
  </h1>
</div>
  
</body>
</html>
 
article, aside, figure, footer, header, hgroup, 
menu, nav, section { 
    display: block; 
}
.main-container {
    margin: 0 auto;
    padding: 0 0 10px 0;
}
h1 { 
    display: table;
}
h1 span { 
    display: table-cell; 
    text-align: center;
}
#left, #right {
    width: 90%; 
 
}
#center {
    display: inline-block; 
    position: relative; 
    top: 0.5em; 
    padding: 0 0.5em; 
}
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers