Zac Anger's Blog

void elements

09 August, 2016

obviously this doesn't apply when using jsx, because everything needs to be closed. but, in jsx, if it can be a self-closed tag (meaning literally any of these but also anything else that doesn't have children), please self-close it.

see what they all have in common?

you can't possibly have anything in any of them, like, between tags. what can you put between an opening and closing line break tag? nothing. so why would you need a closing tag? you wouldn't. so don't close it. none of that <img src="img.jpg"></img> bs. No <br />, and definitely never <link rel="stylesheet" type="text/css" href="styles.css" />.

Submit a bug report