Home >Web Front-end >JS Tutorial >Why Do Some Browsers Reject Self-Closing `` Tags?

Why Do Some Browsers Reject Self-Closing `` Tags?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-27 09:45:10717browse

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 . 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