The source tag in HTML
- 24-07-2022
- Trung Minh
- 0 Comments
The source tag is used to specify multimedia resources for media elements such as video, audio, and images.
The source tag allows you to define media files to be displayed instead depending on media, codec support, or media queries.
For example, if you want to change the image displayed when the user resizes the browser window, then you should use the picture tag in combination with multiple source tags to define the displayed image for each other window size. together.
Using
For example , use the source tag in conjunction with the media tag to change the image displayed when the user resizes the browser window.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>Học html miễn phí tại web888.vn</h1> <picture> <source media="(min-width: 800px)" srcset="black.jpg"> <source media="(min-width: 600px)" srcset="blue.jpg"> <img src="yellow.jpg" alt="Flowers" style="width:auto;"> </picture> </body> </html>