Asked • 04/11/19

How do I give text or an image a transparent background using CSS?

Is it possible, using CSS only, to make the `background` of an element semi-transparent but have the content (text & images) of the element opaque?I'd like to accomplish this without having the text and the background as two separate elements.When trying: Hello world p { position: absolute; background-color: green; filter: alpha(opacity=60); opacity: 0.6; } span { color: white; filter: alpha(opacity=100); opacity: 1; }It looks like child elements are subjected to the opacity of their parents, so `opacity:1` is relative to the `opacity:0.6` of the parent.

1 Expert Answer

By:

Joshua P. answered • 04/14/19

Tutor
4.9 (22)

Unity Video Game and Tool Programmer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.