Set Height and Width of an Image Using Percent with CSS



To set the height and width of an image using %, you can try to run the following code −

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            height: 50%;
            width: 50%;
         }
      </style>
   </head>
   <body>
      <p>Sized image in %</p>
      <img src = "https://www.tutorialspoint.com/videotutorials/assets/videos/courses/155/images/course_155_image.png" alt = "CSS" width = "200" height = "200">
   </body>
</html>
Updated on: 2020-06-22T05:35:38+05:30

845 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements