Skip to content
Related Articles

Related Articles

Improve Article

CSS | Number Data Type

  • Last Updated : 11 Jun, 2020
Geek Week

CSS Value is represented by <number> which takes an integer as a parameter or a number with a fractional component. They can be used by the symbol (+) or (-). The number can be positive or negative. All the digits of the number are 0 to 9 and all are of numeric types.

Syntax:

<number>

Note: No unit associated with numbers.

Examples for valid numbers

23, +90, -76, 0.56, 34.67, 10e4, -4.6e-2

Examples for invalid numbers



23., -+45, 45.7.6

Example 1: The following example demonstrates applying opacity to any element.




<!DOCTYPE html>
<html>
  
<head>
    <style>
        img {
            opacity: 0.5;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks Logo</h1>
  
    <p>
        The opacity property specifies 
        the transparency of an element.
        It takes a number as parameter.
        The lower the value, the image 
        is more transparent 
    </p>
      
    <img src=
        alt="GFG" width="170" height="100">
</body>
  
</html>

Output:

Example 2: The following example shows the opacity property with some changed value.




<!DOCTYPE html>
<html>
  
<head>
    <style>
        img {
            opacity: .11;
        }
    </style>
</head>
  
<body>
  
    <h1>GeeksforGeeks Logo</h1>]
  
    <p>
        The opacity property specifies 
        the transparency of an element.
        It takes a number as parameter.
        The lower the value, the image 
        is more transparent:
    </p>
      
    <img src=
        alt="GFG" width="170" height="100">
</body>
  
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :