why is there a / in the <img> tag question if there is no closing tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why is there a / in the <img> tag question if there is no closing tag?

The <img> is written without the / (forward slash) according to the reading material before the question, but when the test question is presented it asks "what tag is used to insert and image"? <___/> is how the answer is structured and I did receive a correct answer when inputing <img/> in the blank space. Is this a typo?

6th Feb 2020, 12:34 AM
John Thornton
John Thornton - avatar
2 Answers
+ 3
According to the XHTML syntax (which is more strict than HTML5) the self-closing tags should end with /> In HTML this is not mandatory but a good practice to follow. http://xahlee.info/js/html5_non-closing_tag.html
6th Feb 2020, 12:46 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Because there’s no closing tag, it’s “best practice” to include a forward slash. It’s not required, but encouraged
6th Feb 2020, 12:42 AM
Jax
Jax - avatar