October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Use RGBA Colors in CSS

Use RGBA or modern slash-alpha RGB to control color transparency in CSS, while keeping text opaque by applying alpha to the background color only.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use four values for red, green, blue, and alpha: rgba(20, 80, 160, 0.5) makes a blue color 50% opaque. The modern equivalent is rgb(20 80 160 / 50%). Both forms are valid CSS; for a translucent background with opaque text, put alpha on the background color rather than applying opacity to the whole element.

How to write an RGBA color

The traditional syntax uses comma-separated red, green, blue, and alpha components:

As an Amazon Associate I earn from qualifying purchases.

rgba(red, green, blue, alpha)

For example:

.notice {
  background-color: rgba(20, 80, 160, 0.5);
}

In this common numeric notation, each RGB channel is a value from 0 through 255. Alpha controls transparency: use a number from 0 to 1 or a percentage from 0% to 100%.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • 0 or 0%: fully transparent.
  • 0.5 or 50%: half opaque.
  • 1 or 100%: fully opaque.

Alpha is not a 0–255 channel. If you omit alpha in an RGB color, it defaults to fully opaque. See MDN’s RGB function reference and the CSS Color Module Level 4 specification.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Use modern slash-alpha syntax when you prefer it

CSS also allows alpha after a slash, with spaces separating the RGB channels:

.notice {
  background-color: rgb(20 80 160 / 50%);
}

This produces the same color and transparency as rgba(20, 80, 160, 0.5). In the modern form, do not use commas between the channels or combine comma-separated syntax with a slash. Although the modern form uses the name rgb(), it still supports alpha.

Keep text opaque while making a background translucent

Apply alpha to the background color itself, then set the text color separately:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.card {
  background-color: rgb(15 25 40 / 85%);
  color: white;
}

The background color is translucent, while the text remains opaque. Avoid setting opacity on .card when only its background should fade: element-wide opacity affects the element’s rendered contents too.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Choose between RGBA, slash-alpha RGB, and alpha hex

Format Example When it may fit
Comma-separated RGBA rgba(0, 0, 255, 0.5) Alpha is explicit in the function name and familiar to many developers.
Modern slash-alpha RGB rgb(0 0 255 / 50%) A readable choice when writing modern CSS color syntax.
Hex with alpha #ff000080 Compact when your design values are already hexadecimal; the final byte encodes alpha.

In eight-digit hex notation, the form is #RRGGBBAA: the last byte, AA, is alpha. 00 is fully transparent and ff fully opaque. For example, #ff000080 is an approximately half-transparent red. See MDN’s hex color reference.

rgba() has not been removed; it remains a valid legacy alias of rgb(). For newer CSS, slash-alpha syntax is another option. Check the browser compatibility information linked from MDN’s RGB reference if your project has a specific browser-support matrix.

Common mistakes and fixes

  • Using 128 for half alpha: Alpha is a number from 0 to 1 or a percentage. Use 0.5 or 50%, not an 8-bit value.
  • Fading the text along with the background: Use alpha in background-color, not opacity on the containing element.
  • Mixing syntaxes: Write legacy RGBA with commas, such as rgba(20, 80, 160, 0.5), or modern RGB with spaces and a slash, such as rgb(20 80 160 / 50%).
  • Assuming transparent means a particular visible color: A transparent color lets what is behind it show through; the resulting appearance depends on the background beneath it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

See a rendered result with ScreenshotNeo

You can inspect a page with translucent CSS in a real browser screenshot. ScreenshotNeo is a website screenshot API and MCP server; its one-call capture can save you from setting up a browser for this check.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Replace the example URL with a publicly accessible page you want to capture, and provide your API key. See the ScreenshotNeo documentation for API options.

  • Cookie banners are accepted and removed, along with known consent-platform banners, newsletter popups, and chat widgets; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Responses identify the page verdict and billing status in headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with 1,000 screenshots a month and no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.