Use CSS max-width Property for Responsive Image



You can try to run the following code to implement the max-width property for the responsive image

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0">
      <style>
         img {
            max-width: 100%;
            height: auto;
         }
      </style>
   </head>
   <body>
      <p>To check the effect, you need to resize the browser.</p>
      <img src = "https://www.tutorialspoint.com/python/images/python-data-science.jpg" alt = "Python Data Science" width = "400" height = "300">
   </body>
</html>
Updated on: 2020-06-25T06:10:13+05:30

347 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements