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

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: 2020-06-22T05:35:38+05:30

948 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements