CSS Responsive Images

Please Share On:

Definition:

CSS responsive images will automatically resize your images according to your device screen.

Syntax:

img {
  max-width: 100%;
  height: auto;
}

Source Code:

<!DOCTYPE html>
<html>
  <head>
    <style>
      h2{
        text-align: center;
      }
      
      img {
        max-width: 100%;
        height: auto;
      }   
    </style>
  </head>
  
  <body>
    <h2>Responsive Images</h2>
    <img src="https://www.elsebazaar.com/blog/wp-content/uploads/2020/11/Sydney-Harbour-Bridge-View.jpg" alt="Sydney Harbour Bridge"> 
  </body>
</html>

					
					

Output

Click “TRY IT YOURSELF” to see the results and make sure to resize the image to see the responsive image effects.


Donate to support writers.


You may be interested in the following topics:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial