Set the height and width of an image using percent with CSS

CSSWeb DevelopmentFront End Technology

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>
raja
Published on 08-May-2018 12:26:59
Advertisements