Online CSS Opacity Generator
Control element transparency easily with this online CSS opacity generator. Adjust opacity values in real time and instantly get clean CSS code for your projects. Whether you're working with the opacity property, rgba() colors, or modern hex alpha formats, this tool helps you visualize and implement transparency effects quickly.
Contents
Opacity in CSS defines how transparent an element is. The value ranges from 0 (completely transparent) to 1 (fully visible).
opacity: 1→ fully visibleopacity: 0.5→ semi-transparentopacity: 0→ invisible
Basic CSS Opacity Example
.box {
opacity: 0.5;
} This makes the entire element (including text and children) semi-transparent.
Image Opacity Examples
See how different opacity levels affect images. Below examples demonstrate opacity: 0, 0.5, and 1, helping you understand how transparency changes visibility from completely hidden to fully visible.
Easily apply transparency effects to your elements with this interactive opacity generator. Start by selecting the element type whether it is a div box, image, or text then adjust the opacity level using the slider or input field. The preview updates instantly so you can see how the transparency affects your design.
Features
- Choose element type: Div Box, Image, or Text
- Adjust opacity from 0 to 1
- Real-time preview of transparency
- One-click copy CSS code
HTML and CSS code
<img class="opacity" src="/images/HTMLpicture.png" alt="html"> .opacity {
opacity: 0.5;
width: 200px;
height: auto;
} CSS opacity is widely used to create modern and visually appealing UI effects. It helps control transparency for elements like images, backgrounds, and text, making designs more interactive and layered.
- Overlay effects
- Image hover transparency
- Background fade
- UI disabled states
- Modal backdrop
Create dynamic visual effects by animating opacity values over time. This example demonstrates a continuous fade-in and fade-out animation, making elements smoothly transition between visible and transparent states.
Preview Opacity Animation
HTML and CSS Code for Opacity Animation
<img class="opacity-animation" src="/images/HTMLpicture.png" width="200"> .opacity-animation {
Opacity: 0.5;
animation: opacity_fade 3s linear infinite normal;
}
@keyframes opacity_fade {
0% { Opacity: 0 }
25% { Opacity: 1 }
50% { Opacity: 0 }
75% { Opacity: 1 }
100% { Opacity: 0 }
} Create a clean fade animation on hover that smoothly adjusts opacity, adding subtle interactivity and improving the visual experience.
Preview Animation
HTML and CSS Code for Hover Fade Effect
<img class="smooth-hover-opacity" src="/images/HTMLpicture.png" width="200"> .smooth-hover-opacity {
opacity: 0.5;
transition: opacity 0.3s linear;
}
.smooth-hover-opacity:hover {
opacity: 1;
} Use opacity to visually indicate disabled input buttons and inactive states. Lowering the opacity helps users quickly recognize that an element is not interactive, while maintaining a clean and consistent UI design.
Preview Disabled
HTML and CSS Code for Disabled Button
Checkbox <input type="checkbox" disabled>
Radio button <input type="radio" disabled>
Button <button disabled>Disabled button</button>
Textarea <textarea disabled></textarea> .disabled {
opacity: 0.4;
cursor: not-allowed;
}
input:disabled, button:disabled, select:disabled, textarea:disabled {
opacity: 0.4;
cursor: not-allowed;
} What is opacity in CSS?
Opacity in CSS controls how transparent an element is. It uses values from 0 to 1, where 0 means completely invisible and 1 means fully visible. This property affects the entire element, including its content and child elements.
What is the difference between opacity and rgba?
The opacity property applies transparency to the whole element, including text and child elements. In contrast, rgba() controls transparency only for a specific color (usually background), allowing text and inner content to remain fully visible.
How do I make only background transparent?
To make only the background transparent, use rgba() or hex with alpha instead of the opacity property. This way, you can adjust the background transparency without affecting the text or other content inside the element.
.box {
background-color: rgba(0, 0, 0, 0.5); /* transparent background */
color: #ffffff; /* text remains fully visible */
padding: 20px;
} Related links