Home > Web Front-end > HTML Tutorial > How to specify the URL of an image to be used in different situations in HTML?

How to specify the URL of an image to be used in different situations in HTML?

WBOY
Release: 2023-08-26 23:21:12
forward
1150 people have browsed it

How to specify the URL of an image to be used in different situations in HTML?

Use the srcset attribute to specify the URL of an image to be used in different situations in HTML.

Example h2>

You can try running the following code to implement the srcset attribute. Resize your browser to see the different images loaded -

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content="width=device-width, initial-scale = 1.0">
   </head>
   <body>
      <picture>
         <source media = "(min-width: 550px)" srcset = "https://www.tutorialspoint.com/assets/videotutorials/courses/3d_animation_online_training/380_course_211_image.jpg">
         <source media = "(min-width: 400px)" srcset = "https://www.tutorialspoint.com/assets/videotutorials/courses/html_online_training/380_course_216_image.jpg">
         <img src = "https://www.tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg" alt = "Tutorials Library" style = "width:auto;">
      </picture>
   </body>
</html>
Copy after login

The above is the detailed content of How to specify the URL of an image to be used in different situations in HTML?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template