I had the same question, but most of the answers I found did not fit what I needed, until I found CSS technique for a horizontal line with words in the middle.
This solution does not use any JS, and works in just about any situation. Hope it helps.
***** Edit *****
Here is the code I used for my project. In case you are interested, you can see the final result at jtslegal.com. I used it for the titles of all sidebar widgets.
<div id="widget_title">Request a Call</div>
#widget_title { overflow: hidden; padding: 10px 26px 0; }
#widget_title:after, #widget_title:before {
content: '';
display: inline-block;
height: 1px;
width: 100%;
margin: 0;
background: #999;
text-indent: 20px;
position: relative;
vertical-align: middle;
}
#widget_title:after {
left: .5em;
margin-right: -100%;
}
#widget_title:before {
right: .5em;
margin-left: -100%;
}