img elements are self-closing

Basic HTML and HTML5: Add Images to Your Website

You can add images to your website by using the 

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也是如此。

html中的hr直线标签,需要关闭标签吗?

https://www.w3.org/TR/2011/WD-html-markup-20110113/hr.html

参考这里的描述:

The hr element is a void element. An hr element must have a start tag but must not have an end tag.

看中文有些教程网站写必须加关闭标签是错的描述。

Note: In HTML, 

hr

 is a self-closing tag, and therefore doesn’t need a separate closing tag.