I am implementing a project that contains elements that are semantic headers (h3, h4, etc.), are full-width block elements, followed by a vertically centered horizontal line that extends the entire width of the header a la

I know I could take care of this by wrapping each title in a <div> and inserting another block level element after it, but would prefer not to pollute my HTML. My first goal was to use the ::after element in the headers, for example:
.line-header::after { content:'\00a0'; display: inline-block; float: right; width: 55%; margin-top: -12px; border-bottom: 1px solid gray; }
However, this requires creating a fixed width for the ::after element, which obviously does not work with headers of different widths: http://jsfiddle.net/nbSTf/
Any ideas on how to get a variable-width string that fills the space to the right of the title without inserting extra elements into the HTML?
EDIT: Tyriar's answer below (suggesting to draw the line width behind the heading and set the background color to erase the line behind the text) reminded me that this happens before a repeating background image - so, unfortunately, background tricks are not possible.
source share