Setting Element Transparency or Opacity

Description

opacity sets the transparency of an element.

You can use the opacity property to make entire elements and their text content transparent.

The allowed range for this property is from zero to 1, which is from completely transparent from completely opaque.

Example

The following code shows the opacity property.


<!DOCTYPE HTML>
<html>
<head>
<style>
p  {<!--   w w  w.  j  av  a2  s. co  m-->
    padding: 5px;
    border: medium double   black;
    background-color: lightgray;
    font-family: sans-serif;
}
#banana  {
    font-size: x-large;
    border: medium solid white;
    background-color: green;
    color: white;
    opacity: 0.4;
}
a:hover  {
color: red;
}
</style>
</head>
<body>
    <p id="mytext">
        this is a <span  id="banana">test</span>.
        <a href="http://java2s.com">tutorial</a>
    </p>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table