React · Junior · Question 55 of 75
Why does <img src={url}> without a closing slash fail in JSX?
- ✓Correct answer: JSX requires every tag to be closed, so void elements must be self-closing:
<img /> - 2Images must be imported as components
- 3
srcneeds quotes instead of braces
Explanation
JSX is stricter than HTML: <br />, <input /> and any component without children need the closing slash.