Set the 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: 22-Jun-2020

503 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements