Opacity applies to all contained elements, so your text is appropriately faded. Unless your HTML is different than I imagine, so always be sure to post your HTML source. Check out the following in your browser and rendered to PDF:
<body style="background-color:orange;">
<div style="background-color: gray; opacity: .5em; padding: 1em;"><b>WAT WAT</b></div>
</body>
FYI, there is a bug related to cascading though I don't think it's relevant:
https://github.com/dompdf/dompdf/issues/496If you only want your background to be opaque you would use something like
background-color: rgba(192,192,192,.5).
<body style="background-color:orange;">
<div style="background-color: rgba(192,192,192,.5); padding: 1em;"><b>WAT WAT</b></div>
</body>
Unfortunately dompdf doesn't support rgba() yet.
So a little work around:
<body style="background-color:orange;">
<div style="background-color: gray; padding: 1em; opacity: .5;"><div style="opacity: 2;"><b>WAT WAT</b></div></div>
</body>
Which really shouldn't work ... but it does. There are some quirks around opacity that still need to be addressed.