how to make an image smaller in css code example
Example 1: make an image smaller css
css:
.example-class {
width: 400px;
height: auto;
}
html:
<img class="example-class" src="example.jpg"/>
Example 2: resize image html
<!--
Resize image using html
When we add any image in 'src' attribute of 'img' tag then image appears with original size on webpage
and if we want to resize the image we have to add extra attribute i.e. height and width to img tag to resize the image
-->
Simple img tag
<img src="image_path" alt="Image Sample">
With height and width attribute
<img src="image_path" width="200" height="40" alt="Image Sample">
<!--
I hope it will help you.
Namaste
Stay Home Stay Safe
-->
Example 3: css image size adjust
squareImage {
border: 1px solid #ddd;
border-radius: 4px;
width: 150px;
height: auto;
}
Example 4: Scaling Images and Videos css
.container {
width: 50%;
height: 200px;
overflow: hidden;
}
.container img {
max-width: 100%;
height: auto;
display: block;
}