Home >Web Front-end >JS Tutorial >Why Do Some Browsers Reject Self-Closing `` Tags?
Why Browser Interpretation of Script Elements Differs
XHTML browsers often fail to recognize script elements written as . Instead, they only accept the traditional format: . This discrepancy raises questions about browser support for XHTML.
HTML Compatibility Guidelines
The XHTML 1 specification provides the non-normative appendix 'HTML Compatibility Guidelines,' which includes the following rule:
C.3. Element Minimization and Empty Element Content
Empty instances of elements with a non-EMPTY content model (such as title and paragraph) should not be minimized using the / syntax.
XHTML Specification
The XHTML DTD specifies script elements as:
<!ELEMENT script (#PCDATA)>
This specification indicates that script elements contain PCDATA (parsed character data), which cannot be empty. Therefore, according to the HTML Compatibility Guidelines, minimizing