CSS

CSS - Images

CSS - Images

Pictures assume a significant part of any page. However, it isn't prescribed to incorporate plenty of pictures, yet utilize great pictures any place required. CSS assumes a decent part to control picture show. You can set the accompanying picture properties utilizing CSS. 

  • The border property is utilized to set the width of a picture line. 
  • The height property is utilized to set the tallness of a picture. 
  • The width property is utilized to set the width of a picture. 
  • The - moz-opacity property is utilized to set the murkiness of a picture. 

The Image Border Property 

The border property of a picture is utilized to set the width of a picture border. This property can have a worth long or in %. A width of zero pixels implies no border. For example:

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        div{
            border:3px dashed red;
        }
        img{
            height: 300px;
            width: 300px;
        }
    </style>
</head>
<body>
    <div>
        <img src="https://yt3.ggpht.com/ytc/AKedOLQCxwWkeIU4jyhDL-1vXucz-mquq4uPnTsyUtGiyA=s900-c-k-c0x00ffffff-no-rj">
    </div>
</body>
</html>

Output:


The Image Height Property

The height property of a picture is utilized to set the tallness of a picture. This property can have a worth long or in %. While giving worth in %, it applies it in regard of the crate in which a picture is accessible. For example:

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        div{
            border:1px solid red; height:50%;
        }
        img{
            height: 300px;
            width: 300px;
        }
    </style>
</head>
<body>
    <div>
        <img src="https://yt3.ggpht.com/ytc/AKedOLQCxwWkeIU4jyhDL-1vXucz-mquq4uPnTsyUtGiyA=s900-c-k-c0x00ffffff-no-rj">
    </div>
</body>
</html>


The Image Width Property 

The width property of a picture is utilized to set the width of a picture. This property can have a worth long or in %. While giving worth in %, it applies it in regard of the crate in which a picture is accessible.

For example:
<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        div{
            border:1px solid red; width:150px;
        }
        img{
            height: 300px;
            width: 300px;
        }
    </style>
</head>
<body>
    <div>
        <img src="https://yt3.ggpht.com/ytc/AKedOLQCxwWkeIU4jyhDL-1vXucz-mquq4uPnTsyUtGiyA=s900-c-k-c0x00ffffff-no-rj">
    </div>
</body>
</html>

Output:


Top course recommendations for you

    Factorial Program in C
    2 hrs
    Beginner
    3.9K+ Learners
    4.43  (128)
    Jenkins Tutorial
    1 hrs
    Beginner
    7K+ Learners
    4.54  (369)
    Dockerize Spring Boot Application
    1 hrs
    Intermediate
    2.9K+ Learners
    4.37  (111)
    Python Data Structures
    1 hrs
    Beginner
    23.8K+ Learners
    4.54  (1273)
    Fibonacci Series in Java
    2 hrs
    Beginner
    2.4K+ Learners
    4.38  (48)
    Priority Queue in C++
    1 hrs
    Beginner
    1.9K+ Learners
    4.32  (84)
    Introduction to MATLAB
    2 hrs
    Beginner
    18.1K+ Learners
    4.51  (1034)
    Packages in Python
    1 hrs
    Beginner
    5.8K+ Learners
    4.41  (221)
    Palindrome in Python
    2 hrs
    Beginner
    2.4K+ Learners
    4.69  (62)