Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Self-closing a <TD /> tag

Tags:

html

I came across a code where a developer attempted to close an empty table cell like this <TD /> instead of <td></td>.

Is <td /> valid? When is it appropriate to close a tag like <tag />? What language does it come from originally?

like image 274
santa Avatar asked Oct 20 '25 14:10

santa


1 Answers

Non-HTML Compatible XHTML (so not if you want to use a text/html content-type or support IE 8 or older).

If an element permits content (e.g., the div element) but an instance of that element has no content (e.g., an empty section), DO NOT use the "minimized" tag syntax (e.g., <div />).

— http://www.w3.org/TR/xhtml-media-types/#C_3

like image 100
Quentin Avatar answered Oct 23 '25 05:10

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!