Basic HTML and HTML5: Add Images to Your Website
img
element, and point to a specific image’s URL using the
src
attribute.
An example of this would be:
<img src="https://www.your-image-source.com/your-image.jpg">
Note that
img
elements are self-closing.
All
img
elements must have an
alt
attribute. The text inside an
alt
attribute is used for screen readers to improve accessibility and is displayed if the image fails to load.
Note: If the image is purely decorative, using an empty
alt
attribute is a best practice.
Ideally the
alt
attribute should not contain special characters unless needed.
注意:img不需要加闭合, hr也是如此。