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

Why Do Some Browsers Reject Self-Closing Script Tags?

DDD
Release: 2024-12-16 16:11:18
Original
601 people have browsed it

Why Do Some Browsers Reject Self-Closing Script Tags?

Self-Closing Script Elements: A Browser Anomaly

Browsers, notably Microsoft Internet Explorer versions 6 through 8 beta 2, exhibit peculiar behavior when it comes to self-closing script elements (), these self-closing elements are not recognized as valid script tags by the browser. This inconsistent behavior raises concerns about browser support for XHTML.

Delving into the technical reasoning behind this non-recognition, we turn to the XHTML 1 specification's non-normative appendix 'HTML Compatibility Guidelines.' Specifically, section C.3. Element Minimization and Empty Element Content states:

Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use

and not

).

Examining the XHTML DTD, we find that script elements are defined as:

This definition specifies that script elements must contain PCDATA (parsed character data), indicating that they cannot be empty. Therefore, according to the XHTML Compatibility Guidelines, script elements should not be minimized as

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template