There are many ways in which we can set the background of an element in HTML Opaque using CSS. Let's take a look at a few examples.
Example 1: Opacity Property
<div class="div-opaque-05">Opacity 0.5</div>
<div class="div-opaque-08">Opacity 0.8</div>
<style>
.div-opaque-05 {
background-color: #000;
opacity: 0.5;
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: #000;
opacity: 0.8;
color: #fff;
padding:10px
}
<style>
Opacity 0.5
Opacity 0.8
Example 2: Using Hex Color Code Alpha Channel
.div-opaque-05 {
background-color: #00000080;
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: #00000050;
color: #fff;
padding:10px
}
Example 3: Using RGBA Background Color
.div-opaque-05 {
background-color: rgba(0, 0, 255, 0.3);
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: rgba(0, 0, 255, 0.8);
color: #fff;
padding:10px
}

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to CSS,
- Elegant CSS Box Shadows Ideas
- How to Vertically Center Align Text in a Div using CSS Code Example
- How to Center Align Image in Bootstrap
- Change CSS Background Opacity with Examples
- Tutorial : Simple Lightweight Pure CSS based Vertical Navigation Menu
- Simple CSS Grid Example
- CSS: Apply opacity only for div background and not text
- How to create a circular Image using pure CSS Code
- How to place two div elements next to each other
- Responsive Web Design with CSS Media Queries: A Beginner's Tutorial [Updated for 2023]
- Add scroll to div element in HTML Css
- How to make div or text in html unselectable using CSS
- reCAPTCHA Implementation Tutorial
- Set Falling Show on Website for Christmas using Pure CSS Code
- How to set CSS background-Image Property
- List of 32 CSS cursors web developers must know about
- 10 Must Know CSS Border Styles with Examples
- How to make jsfiddle bootstrap ready
- Horizontally Center Align
- Tailwind CSS Hello World Example
- align image at middle of div element
- Only Chessboard using HTML and CSS Code Example
More Posts:
- How to make ZSH as the default shell on Ubuntu - zsh
- How to view the desktop when using macOS Stage Manager? - MacOS
- Eclipse : Workspace was written with an older version of the product and will be updated - Eclipse
- Make Android TextView Clickable like Buttons - Android
- [Solved] Dynamic Web Module 3.0 requires Java 1.6 or newer Mac OSX - Mac-OS-X
- Find installed Gradle version command - Gradle
- SharePoint Server 2016 setup error - A system restart from a previous installation or update is pending. Restart your computer and run setup to continue. - SharePoint
- You're not on Teams yet, but you can set it up for your organization. [Microsoft Teams Login Error] - Microsoft