Why don't self-closing script elements work?

DeepMohinman
Posts: 2
Joined: Tue Aug 02, 2022 3:33 pm

Why don't self-closing script elements work?

Post by DeepMohinman »

What is the reason browsers do not correctly recognize:

<script src="foobar.js" /> <!-- self-closing script element -->
Only this is recognized:

<script src="foobar.js"></script>
Does this break the concept of XHTML support?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Why don't self-closing script elements work?

Post by Radu »

Hi,

There is this XHTML compatibility guideline that browsers obey:

https://www.w3.org/TR/xhtml1/guidelines.html
Element Minimization and Empty Element Content

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 <p> </p> and not <p />).
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply