This question already has an answer here:
How do I make the cross-browser (including Internet Explorer 6) transparency for the background of a div
while the text remains opaque?
I need to do it without using any library such as jQuery, etc. (But if you know of a library that does it I'd love to know so I can look at their code).
I've created that effect on my blog Landman Code.
What I did was
The important thing that every padding/margin and content must be the same in both the .Background as .Foreground.
Relaxing your requirement to work on IE6 and legacy browsers you can use ::before and display: inline-block
Demo at http://jsfiddle.net/KVyFH/172/
It will work on any modern browser
I use an alpha-transparent PNG for that:
For IE6, you'd need to use a PNG fix (1, 2), though.
Use rgba!
via http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/
Thanks @davy-landmann for https://stackoverflow.com/a/638064/417153. That's what I was looking for! Same effect with LESS code: