Code highlights logo

Learn

Visual Rules

Opacity

The opacity property in CSS allows you to set the transparency of an element. This means that you can adjust the level of visibility of an element from fully opaque to completely transparent.

The opacity value ranges from 0 to 1. A value of 0 means that the element will be completely transparent, while a value of 1 means that the element will be fully opaque.

You can set the opacity property for any element whether it's text, image, background, or border. The property can be applied to both the parent container and its child elements.

1/* Set opacity for a parent container*/
2.parent {
3 opacity: 0.5; /* The value can range from 0 to 1 */
4}
5
6/* Set opacity for a child element*/
7.child {
8 opacity: 0.75; /* The value can range from 0 to 1 */
9}

Keep in mind that when you adjust an element's opacity, it can also affect the opacity of its child elements. This means that if you set the opacity of a parent container, it will also affect the opacity of its child elements.

It is important to use opacity sparingly and intentionally because it can affect the content's readability and accessibility. Also, avoid using opacity on interactive elements such as buttons and links because it makes them harder to click.

In conclusion, opacity is a useful CSS property when used properly to create an attractive and unique design. However, it must be used cautiously to avoid compromising the readability and accessibility of the content.


Instructions

1.

In the existing code, change the opacity of the .title class to 0.6.

Sign up to start coding

Already have an account?

Sign In

Course content