I have a variable-width header that should have a background color as wide as the text (no wider). The only way I can do this (without additional markup) is to set the display to the built-in block or put it to the left. The problem then is that I cannot center the header (another requirement).
The closest thing I have so far is to set position: relative; on the floating title by clicking on it 50% on the left and then pulling it back 25% with a negative margin, however this does not always center the title. It must remain in the document stream, therefore position: absolute; - this is another no-go.
If you know a way to do this with CSS with just no extra markup , please let me know (the pseudo elements are fine, I don't care about IE7 support)!
joshnh
source share