How to Make Only the Background Color Transparent in CSS
To make only a CSS background color translucent, put an alpha value in the color, as in background-color: rgb(48 145 185 / 45%). opacity: 0.45 applies to the element and its descendants as one composite, so the text and border fade too.
What opacity and background alpha affect
An alpha of 0 is fully transparent and 1 is fully opaque. 45% and 0.45 both mean 45% opaque. The older comma-separated rgba(48, 145, 185, 0.45) means the same color. Setting opacity: 1 on a child does not undo parent opacity. CSS Color · rgb() and rgba() CSS Color · opacity
Compare both methods with the same color
Save the code as background-alpha.html and open it. Both cards use the same blue, and a CSS gradient supplies the stripes behind them. In the first card the border and text fade with the background. In the second, the stripes show through the background while the text and borders stay opaque.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Compare background alpha and opacity</title>
<style>
body { margin: 20px; font: 16px/1.6 system-ui, sans-serif; color: #203348; }
* { box-sizing: border-box; }
h1 { font-size: 24px; }
.stage { max-width: 600px; padding: 20px; display: grid; gap: 20px;
background: repeating-linear-gradient(45deg, #dce9f4 0 14px, #fff 14px 28px); }
.card { padding: 20px; background-color: #3091b9; color: #153648;
border: 2px solid #153648; }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card p { margin: 0; }
.whole { opacity: 0.45; }
.alpha { background-color: rgb(48 145 185 / 45%); }
</style>
</head>
<body>
<h1>Make only the background translucent</h1>
<div class="stage">
<section class="card whole">
<h2>opacity: 0.45</h2>
<p>The background, text, and border all fade.</p>
</section>
<section class="card alpha">
<h2>Background color alpha: 45%</h2>
<p>The stripes show through, and the text and border stay opaque.</p>
</section>
</div>
</body>
</html>
Change only the second card’s 45% to 80%. The blue becomes more solid and less of the pattern shows. At 0% the color disappears and the text and borders remain. Restore the original value afterward.
Check background images and text contrast
background-color: transparent also removes only the paint from the background color. The clickable area and any background image remain. An opaque background image on that element is painted above the color and can hide the change. Temporarily disable background-image in developer tools and check for a later background shorthand that resets the color. CSS Backgrounds and Borders · background-color
The visible shade depends on the color or image behind it. Even opaque text can lose contrast over a light or dark patch. For a message over a varied photo, consider a more opaque color or a separate area for the text.




