<p>What is the reason browsers do not correctly recognize:</p>

<pre><code>&lt;script src="foobar.js" /&gt; &lt;!-- self-closing script element --&gt;
</code></pre>

<p>Only this is recognized:</p>

<pre><code>&lt;script src="foobar.js"&gt;&lt;/script&gt;
</code></pre>

<p>Does this break the concept of XHTML support?</p>

<p>Note: This statement is correct at least for all IE (6-8 beta 2).</p>

[{'answer_id': 69984, 'author': 'squadette', 'author_id': 7754, 'author_profile': 'https://Stackoverflow.com/users/7754', 'pm_score': 10, 'selected': True, 'text': '<p>The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:</p>\n<p><a href="http://www.w3.org/TR/xhtml1/#C_3" rel="noreferrer">С.3. Element Minimization and Empty Element Content</a></p>\n<blockquote>\n<p>Given an empty instance of an element whose content model is not <code>EMPTY</code> (for example, an empty title or paragraph) do not use the minimized form (e.g. use <code>&lt;p&gt; &lt;/p&gt;</code> and not <code>&lt;p /&gt;</code>).</p>\n</blockquote>\n<p><a href="http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict" rel="noreferrer">XHTML DTD</a> specifies script elements as:</p>\n<pre><code>&lt;!-- script statements, which may include CDATA sections --&gt;\n&lt;!ELEMENT script (#PCDATA)&gt;\n</code></pre>\n'}, {'answer_id': 69996, 'author': 'rpetrich', 'author_id': 4007, 'author_profile': 'https://Stackoverflow.com/users/4007', 'pm_score': 5, 'selected': False, 'text': '<p>Unlike XML and XHTML, HTML has no knowledge of the self-closing syntax.  Browsers that interpret XHTML as HTML don\'t know that the <code>/</code> character indicates that the tag should be self-closing; instead they interpret it like an empty attribute and the parser still thinks the tag is \'open\'.</p>\n\n<p>Just as <code>&lt;script defer&gt;</code> is treated as <code>&lt;script defer="defer"&gt;</code>, <code>&lt;script /&gt;</code> is treated as <code>&lt;script /="/"&gt;</code>.</p>\n'}, {'answer_id': 70235, 'author': 'JacquesB', 'author_id': 7488, 'author_profile': 'https://Stackoverflow.com/users/7488', 'pm_score': 6, 'selected': False, 'text': '<p>Internet Explorer 8 and earlier do not support XHTML parsing. Even if you use an XML declaration and/or an XHTML doctype, old IE still parse the document as plain HTML. And in plain HTML, the self-closing syntax is not supported. The trailing slash is just ignored, you have to use an explicit closing tag.</p>\n<p>Even browsers with support for XHTML parsing, such as <a href="https://learn.microsoft.com/en-us/archive/blogs/ie/xhtml-in-ie9" rel="nofollow noreferrer">IE 9 and later</a>, will still parse the document as HTML unless you serve the document with a XML content type. But in that case old IE will not display the document at all!</p>\n'}, {'answer_id': 70288, 'author': 'joelhardi', 'author_id': 11438, 'author_profile': 'https://Stackoverflow.com/users/11438', 'pm_score': 8, 'selected': False, 'text': '<p>To add to what Brad and squadette have said, the self-closing XML syntax <code>&lt;script /&gt;</code> actually <strong>is</strong> correct XML, but for it to work in practice, your web server also needs to send your documents as properly formed XML with an XML mimetype like <code>application/xhtml+xml</code> in the HTTP Content-Type header (and <em>not</em> as <code>text/html</code>).</p>\n\n<p>However, sending an XML mimetype will cause your pages not to be parsed by IE7, which only likes <code>text/html</code>.</p>\n\n<p>From <a href="http://www.w3.org/TR/xhtml-media-types/" rel="noreferrer">w3</a>:</p>\n\n<blockquote>\n  <p>In summary, \'application/xhtml+xml\'\n  SHOULD be used for XHTML Family\n  documents, and the use of \'text/html\'\n  SHOULD be limited to HTML-compatible\n  XHTML 1.0 documents. \'application/xml\'\n  and \'text/xml\' MAY also be used, but\n  whenever appropriate,\n  \'application/xhtml+xml\' SHOULD be used\n  rather than those generic XML media\n  types.</p>\n</blockquote>\n\n<p>I puzzled over this a few months ago, and the only workable (compatible with FF3+ and IE7) solution was to use the old <code>&lt;script&gt;&lt;/script&gt;</code> syntax with <code>text/html</code> (HTML syntax + HTML mimetype).</p>\n\n<p>If your server sends the <code>text/html</code> type in its HTTP headers, even with otherwise properly formed XHTML documents, FF3+ will use its HTML rendering mode which means that <code>&lt;script /&gt;</code> will not work (this is a change, Firefox was previously less strict).</p>\n\n<p>This will happen regardless of any fiddling with <code>http-equiv</code> meta elements, the XML prolog or doctype inside your document -- Firefox branches once it gets the <code>text/html</code> header, that determines whether the HTML or XML parser looks inside the document, and the HTML parser does not understand <code>&lt;script /&gt;</code>.</p>\n'}, {'answer_id': 71836, 'author': 'Mike Dimmick', 'author_id': 6970, 'author_profile': 'https://Stackoverflow.com/users/6970', 'pm_score': 4, 'selected': False, 'text': '<p>Internet Explorer 8 and older don\'t support the proper MIME type for XHTML, <code>application/xhtml+xml</code>. If you\'re serving XHTML as <code>text/html</code>, which you have to for these older versions of Internet Explorer to do anything, it will be interpreted as HTML 4.01. You can only use the short syntax with any element that permits the closing tag to be omitted. See the <a href="https://www.w3.org/TR/html401/" rel="nofollow noreferrer">HTML 4.01 Specification</a>.</p>\n<p>The XML \'short form\' is interpreted as an attribute named /, which (because there is no equals sign) is interpreted as having an implicit value of &quot;/&quot;. This is strictly wrong in HTML 4.01 - undeclared attributes are not permitted - but browsers will ignore it.</p>\n<p>IE9 and later <a href="https://learn.microsoft.com/en-us/archive/blogs/ie/xhtml-in-ie9" rel="nofollow noreferrer">support XHTML 5</a> served with <code>application/xhtml+xml</code>.</p>\n'}, {'answer_id': 71998, 'author': 'Marijn', 'author_id': 12038, 'author_profile': 'https://Stackoverflow.com/users/12038', 'pm_score': 5, 'selected': False, 'text': '<p>The people above have already pretty much explained the issue, but one thing that might make things clear is that, though people use <code>&lt;br/&gt;</code> and such all the time in HTML documents, any <code>/</code> in such a position is basically ignored, and only used when trying to make something both parseable as XML and HTML. Try <code>&lt;p/&gt;foo&lt;/p&gt;</code>, for example, and you get a regular paragraph.</p>\n'}, {'answer_id': 3327807, 'author': 'greim', 'author_id': 127040, 'author_profile': 'https://Stackoverflow.com/users/127040', 'pm_score': 7, 'selected': False, 'text': "<p>In case anyone's curious, the ultimate reason is that HTML was originally a dialect of SGML, which is XML's weird older brother. In SGML-land, elements can be specified in the DTD as either self-closing (e.g. BR, HR, INPUT), implicitly closeable (e.g. P, LI, TD), or explicitly closeable (e.g. TABLE, DIV, SCRIPT). XML, of course, has no concept of this.</p>\n\n<p>The tag-soup parsers used by modern browsers evolved out of this legacy, although their parsing model isn't pure SGML anymore. And of course, your carefully-crafted XHTML is being treated as badly-written SGML-inspired tag-soup unless you send it with an XML mime type. This is also why...</p>\n\n<pre><code>&lt;p&gt;&lt;div&gt;hello&lt;/div&gt;&lt;/p&gt;\n</code></pre>\n\n<p>...gets interpreted by the browser as:</p>\n\n<pre><code>&lt;p&gt;&lt;/p&gt;&lt;div&gt;hello&lt;/div&gt;&lt;p&gt;&lt;/p&gt;\n</code></pre>\n\n<p>...which is the recipe for a lovely obscure bug that can throw you into fits as you try to code against the DOM.</p>\n"}, {'answer_id': 13098915, 'author': 'defau1t', 'author_id': 724764, 'author_profile': 'https://Stackoverflow.com/users/724764', 'pm_score': 5, 'selected': False, 'text': '<p>The self closing script tag won\'t work, because the script tag can contain inline code, and HTML is not smart enough to turn on or off that feature based on the presence of an attribute.</p>\n\n<blockquote>\n  <p>On the other hand, HTML does have an excellent tag for including\n  references to outside resources: the <code>&lt;link&gt;</code> tag, and it can be\n  self-closing. It\'s already used to include stylesheets, RSS and Atom\n  feeds, canonical URIs, and all sorts of other goodies. Why not\n  JavaScript?</p>\n</blockquote>\n\n<p>If you want the script tag to be self enclosed you can\'t do that as I said, but there is an alternative, though not a smart one. You can use the self closing link tag and link to your JavaScript by giving it a type of text/javascript and rel as script, something like below:</p>\n\n<pre><code>&lt;link type="text/javascript" rel ="script" href="/path/tp/javascript" /&gt;\n</code></pre>\n'}, {'answer_id': 28719226, 'author': 'Sheepy', 'author_id': 893578, 'author_profile': 'https://Stackoverflow.com/users/893578', 'pm_score': 8, 'selected': False, 'text': '<p>Others have answered "how" and quoted spec. Here is the real story of "why no <code>&lt;script/&gt;</code>", after many hours digging into bug reports and mailing lists.</p>\n\n<hr>\n\n<p><strong>HTML 4</strong></p>\n\n<p>HTML 4 is based on <a href="http://www.iso.org/iso/catalogue_detail.htm?csnumber=16387" rel="noreferrer">SGML</a>.</p>\n\n<p>SGML has some <a href="https://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language#SHORTTAG" rel="noreferrer">shorttags</a>, such as <code>&lt;BR//</code>, <code>&lt;B&gt;text&lt;/&gt;</code>, <code>&lt;B/text/</code>, or <code>&lt;OL&lt;LI&gt;item&lt;/LI&lt;/OL&gt;</code>.\nXML takes the first form, redefines the ending as ">" (SGML is flexible), so that it becomes <code>&lt;BR/&gt;</code>.</p>\n\n<p>However, HTML did not redfine, so <code>&lt;SCRIPT/&gt;</code> <a href="https://stackoverflow.com/a/3201889/893578"><em>should</em> mean</a> <code>&lt;SCRIPT&gt;&gt;</code>. <br>\n(Yes, the \'>\' should be part of content, and the tag is still <em>not</em> closed.)</p>\n\n<p>Obviously, this is incompatible with XHTML and <em>will</em> break many sites (by the time browsers were mature enough <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=47522" rel="noreferrer">to care</a> <a href="https://bugs.webkit.org/show_bug.cgi?id=6393" rel="noreferrer">about this</a>), so <a href="https://stackoverflow.com/a/9619296/893578">nobody implemented shorttags</a> and the specification <a href="http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.3" rel="noreferrer">advises against them</a>.</p>\n\n<p>Effectively, all \'working\' self-ended tags are tags with prohibited end tag on technically non-conformant parsers and are in fact invalid.\nIt was W3C which <a href="https://www.webkit.org/blog/68/understanding-html-xml-and-xhtml/" rel="noreferrer">came up with this hack</a> to help transitioning to XHTML by making it <a href="http://www.w3.org/TR/xhtml1/#guidelines" rel="noreferrer">HTML-compatible</a>.</p>\n\n<p>And <code>&lt;script&gt;</code>\'s end tag is <a href="http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.1" rel="noreferrer">not prohibited</a>.</p>\n\n<p><strong>"Self-ending" tag is a hack in HTML 4 and is meaningless.</strong></p>\n\n<hr>\n\n<p><strong>HTML 5</strong></p>\n\n<p>HTML5 has <a href="https://html.spec.whatwg.org/multipage/syntax.html#elements-2" rel="noreferrer">five types of tags</a> and only \'void\' and \'foreign\' tags are <a href="https://html.spec.whatwg.org/multipage/syntax.html#syntax-tags" rel="noreferrer">allowed to be self-closing</a>.</p>\n\n<p>Because <code>&lt;script&gt;</code> is not void (it <em>may</em> have content) and is not foreign (like MathML or SVG), <code>&lt;script&gt;</code> cannot be self-closed, regardless of how you use it.</p>\n\n<p>But why? Can\'t they regard it as foreign, make special case, or something?</p>\n\n<p>HTML 5 aims to be <a href="https://html.spec.whatwg.org/multipage/introduction.html#history-2" rel="noreferrer">backward-compatible</a> with <em>implementations</em> of HTML 4 and XHTML 1.\nIt is not based on SGML or XML; its syntax is mainly concerned with documenting and uniting the implementations.\n(This is why <code>&lt;br/&gt;</code> <code>&lt;hr/&gt;</code> etc. are <a href="https://html.spec.whatwg.org/multipage/syntax.html#start-tags" rel="noreferrer">valid HTML 5</a> despite being invalid HTML4.)</p>\n\n<p>Self-closing <code>&lt;script&gt;</code> is one of the tags where implementations used to differ.\nIt <a href="https://www.webkit.org/blog/1273/the-html5-parsing-algorithm/" rel="noreferrer">used to work in Chrome, Safari</a>, <a href="http://www.opera.com/docs/changelogs/windows/900b1/" rel="noreferrer">and Opera</a>; to my knowledge it never worked in Internet Explorer or Firefox.</p>\n\n<p><a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/2009Aug/0101.html" rel="noreferrer">This was discussed</a> when HTML 5 was being drafted and got rejected because it <a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/2009Aug/0104.html" rel="noreferrer">breaks</a> <a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/2009Aug/0117.html" rel="noreferrer">browser</a> <a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/2009Aug/0119.html" rel="noreferrer">compatibility</a>.\nWebpages that self-close script tag may not render correctly (if at all) in old browsers.\nThere were <a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/2009Aug/0384.html" rel="noreferrer">other proposals</a>, but they can\'t solve the compatibility problem either.</p>\n\n<p>After the draft was released, WebKit updated the parser to be in conformance.</p>\n\n<p><strong>Self-closing <code>&lt;script&gt;</code> does not happen in HTML 5 because of backward compatibility to HTML 4 and XHTML 1.</strong></p>\n\n<hr>\n\n<p><strong>XHTML 1 / XHTML 5</strong></p>\n\n<p>When <em>really</em> served as XHTML, <code>&lt;script/&gt;</code> is really closed, as <a href="https://stackoverflow.com/a/70288/893578">other answers</a> have stated.</p>\n\n<p>Except that <a href="http://www.w3.org/TR/xhtml1/#media" rel="noreferrer">the spec says</a> it <em>should</em> have worked when served as HTML:</p>\n\n<blockquote>\n  <p>XHTML Documents ... may be labeled with the Internet Media Type "text/html" [RFC2854], as they are compatible with most HTML browsers.</p>\n</blockquote>\n\n<p>So, what happened?</p>\n\n<p>People <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=67646" rel="noreferrer">asked Mozilla</a> to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=107904" rel="noreferrer">let Firefox parse</a> conforming documents as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=109837" rel="noreferrer">XHTML</a> regardless of the specified content header (known as <a href="https://en.wikipedia.org/wiki/Content_sniffing" rel="noreferrer">content sniffing</a>).\nThis would have allowed self-closing scripts, and content sniffing <a href="http://blogs.msdn.com/b/ie/archive/2005/02/01/364581.aspx" rel="noreferrer">was necessary</a> anyway because web hosters were not mature enough to serve the correct header; IE was <a href="https://msdn.microsoft.com/en-us/library/ie/ms775147%28v=vs.85%29.aspx" rel="noreferrer">good at it</a>.</p>\n\n<p>If the <a href="https://en.wikipedia.org/wiki/Browser_wars#First_browser_war" rel="noreferrer">first browser war</a> didn\'t end with IE 6, XHTML may have been on the list, too. But it did end. And IE 6 <a href="http://blog.isotoma.com/2008/01/xhtml-ccs-crashes-ie6/" rel="noreferrer">has a problem</a> with XHTML.\nIn fact IE <a href="https://stackoverflow.com/questions/268526/blank-page-in-ie6">did not support</a> the correct MIME type <a href="http://blogs.msdn.com/b/ie/archive/2005/09/15/467901.aspx" rel="noreferrer">at all</a>, forcing <em>everyone</em> to use <code>text/html</code> for XHTML because IE held <a href="https://en.wikipedia.org/wiki/Usage_share_of_web_browsers#TheCounter.com_.282000_to_2009.29" rel="noreferrer">major market share</a> for a whole decade.</p>\n\n<p>And also content sniffing <a href="http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx" rel="noreferrer">can be</a> <a href="http://www.h-online.com/security/features/Risky-MIME-sniffing-in-Internet-Explorer-746229.html" rel="noreferrer">really bad</a> and people are saying <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=68421" rel="noreferrer">it should be stopped</a>.</p>\n\n<p>Finally, it turns out that the W3C <a href="http://lists.w3.org/Archives/Public/www-html/2000Sep/0024.html" rel="noreferrer">didn\'t mean XHTML to be sniffable</a>: the document is <em>both</em>, HTML and XHTML, and <code>Content-Type</code> rules.\nOne can say they were standing firm on "just follow our spec" and <a href="http://lemire.me/blog/archives/2006/10/30/reinventing-html-or-yes-we-admit-it-xhtml-failed/" rel="noreferrer">ignoring what was practical</a>. A mistake that <a href="https://www.cnet.com/news/an-epitaph-for-the-web-standard-xhtml-2/" rel="noreferrer">continued</a> into later XHTML versions.</p>\n\n<p>Anyway, this decision <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=109837#c11" rel="noreferrer">settled the matter</a> for Firefox.\nIt was 7 years before Chrome <a href="https://en.wikipedia.org/wiki/Google_Chrome#Public_release" rel="noreferrer">was born</a>; there were no other significant browser. Thus it was decided.</p>\n\n<p><strong>Specifying the doctype alone does not trigger XML parsing because of following specifications.</strong></p>\n'}, {'answer_id': 45746061, 'author': 'Bekim Bacaj', 'author_id': 5896426, 'author_profile': 'https://Stackoverflow.com/users/5896426', 'pm_score': 3, 'selected': False, 'text': '<h2>That\'s because SCRIPT TAG is not a VOID ELEMENT.</h2>\n\n<p>In an <em>HTML Document</em> - VOID ELEMENTS <strong>do not</strong> need a "closing tag" at all!</p>\n\n<p>In <em>xhtml</em>, everything is Generic, therefore they all need <strong>termination</strong> e.g. a "closing tag"; Including br, a simple line-break, as <code>&lt;br&gt;&lt;/br&gt;</code> or its <em>shorthand</em> <code>&lt;br /&gt;</code>.</p>\n\n<p>However, a Script Element is never a void or a parametric Element, because <em>script tag</em> before anything else, is a Browser Instruction, not a Data Description declaration.</p>\n\n<p>Principally, a Semantic Termination Instruction e.g., a "closing tag" is only needed for processing instructions who\'s semantics cannot be terminated by a succeeding tag. For instance: </p>\n\n<p><code>&lt;H1&gt;</code> semantics cannot be terminated by a following <code>&lt;P&gt;</code> because it doesn\'t carry enough of its own semantics to override and therefore terminate the previous H1 instruction set. Although it will be able to break the <strong>stream</strong> into a new paragraph line, it is not "strong enough" to override the present font size &amp; style line-height <em>pouring down the stream</em>, i.e leaking from H1 (because P doesn\'t have it). </p>\n\n<p>This is how and why the "/" (termination) signalling has been invented. </p>\n\n<p>A generic <em>no-description</em> termination Tag like <code>&lt; /&gt;</code>, would have sufficed for any single fall off the encountered cascade, e.g.: <code>&lt;H1&gt;Title&lt; /&gt;</code> but that\'s not always the case, because we also want to be capable of "nesting", multiple intermediary tagging of the Stream: split into torrents before wrapping / falling onto another cascade. As a consequence a generic terminator such as <code>&lt; /&gt;</code> would not be able to determine the target of a property to terminate. For example: <code>&lt;b&gt;</code><strong>bold</strong> <code>&lt;i&gt;</code><strong><em>bold-italic</em></strong> <code>&lt; /&gt;</code> <em>italic</em> <code>&lt;/&gt;</code>normal. Would undoubtedly fail to get our intention right and would most probably interpret it as <strong>bold <em>bold-itallic</em> bold</strong> normal.</p>\n\n<p>This is how the <strong>notion</strong> of a wrapper ie., container was born. (These notions are so similar that it is impossible to discern and sometimes the same element may have both. <code>&lt;H1&gt;</code> is both wrapper and container at the same time. Whereas <code>&lt;B&gt;</code> only a semantic wrapper). We\'ll need a plain, no semantics container. And of course the invention of a DIV Element came by. </p>\n\n<p>The DIV element is actually a 2BR-Container. Of course the coming of CSS made the whole situation weirder than it would otherwise have been and caused a great confusion with many great consequences - indirectly!</p>\n\n<p>Because with CSS you could easily override the native pre&amp;after BR behavior of a newly invented DIV, it is often referred to, as a "do nothing container". Which is, naturally wrong! DIVs are block elements and will natively break the line of the stream both before and after the end signalling. Soon the WEB started suffering from page DIV-itis. Most of them still are.</p>\n\n<p>The coming of CSS with its capability to fully override and completely redefine the native behavior of any HTML Tag, somehow managed to confuse and blur the whole meaning of HTML existence...</p>\n\n<p>Suddenly all HTML tags appeared as if obsolete, they were defaced, stripped of all their original meaning, identity and purpose. Somehow you\'d gain the impression that they\'re no longer needed. Saying: A single container-wrapper tag would suffice for all the data presentation. Just add the required attributes. Why not have meaningful tags instead; Invent tag names as you go and let the CSS bother with the rest.</p>\n\n<p>This is how xhtml was born and of course the great blunt, paid so dearly by new comers and a distorted vision of what is what, and what\'s the damn purpose of it all. W3C went from World Wide Web to What Went Wrong, Comrades?!!</p>\n\n<p>The purpose of HTML is <strong>to stream</strong> meaningful data to the human recipient.</p>\n\n<p>To deliver Information.</p>\n\n<p>The formal part is there to only assist the clarity of information delivery.\nxhtml doesn\'t give the slightest consideration to the information. - To it, the information is absolutely irrelevant.</p>\n\n<p>The most important thing in the matter is to know and be able to understand that <strong>xhtml is not just a version of some extended HTML</strong>, xhtml is a completely different beast; grounds up; and therefore <strong>it is wise to keep them separate.</strong> </p>\n'}, {'answer_id': 47424940, 'author': 'myf', 'author_id': 540955, 'author_profile': 'https://Stackoverflow.com/users/540955', 'pm_score': 2, 'selected': False, 'text': '<p>Difference between \'true XHTML\', \'faux XHTML\' and \'ordinary HTML\' as well as importance of the server-sent MIME type had been <a href="https://stackoverflow.com/a/70288/540955">already described here well</a>.</p>\n<p>If you want to try it out right now, here is simple editable snippet with live preview including self-closed script tag (see <code>&lt;script src=&quot;data:text/javascript,/*functionality*/&quot; /&gt;</code>) and XML entity (unrelated, see <code>&amp;x;</code>).</p>\n<p>As you can see, depending on the MIME type of embedding document  the data-URI JavaScript functionality is either executed and consecutive text displayed (in <code>application/xhtml+xml</code> mode) or not executed and consecutive text \'devoured\' by the script (in <code>text/html</code> mode).</p>\n<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">\r\n<div class="snippet-code">\r\n<pre class="snippet-code-css lang-css prettyprint-override"><code>div { display: flex; }\ndiv + div {flex-direction: column; }</code></pre>\r\n<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;Mime type: &lt;label&gt;&lt;input type="radio" onchange="t.onkeyup()" id="x" checked  name="mime"&gt; application/xhtml+xml&lt;/label&gt;\n&lt;label&gt;&lt;input type="radio" onchange="t.onkeyup()" name="mime"&gt; text/html&lt;/label&gt;&lt;/div&gt;\n&lt;div&gt;&lt;textarea id="t" rows="4" \nonkeyup="i.src=\'data:\'+(x.checked?\'application/xhtml+xml\':\'text/html\')+\',\'+encodeURIComponent(t.value)"\n&gt;&lt;?xml version="1.0"?&gt;\n&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"\n[&lt;!ENTITY x "true XHTML"&gt;]&gt;\n&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;\n&lt;body&gt;\n  &lt;p&gt;\n    &lt;span id="greet" swapto="Hello"&gt;Hell, NO :(&lt;/span&gt; &amp;x;.\n    &lt;script src="data:text/javascript,(g=document.getElementById(\'greet\')).innerText=g.getAttribute(\'swapto\')" /&gt;\n    Nice to meet you!\n    &lt;!-- \n      Previous text node and all further content falls into SCRIPT element content in text/html mode, so is not rendered. Because no end script tag is found, no script runs in text/html\n    --&gt;\n  &lt;/p&gt;\n&lt;/body&gt;\n&lt;/html&gt;&lt;/textarea&gt;\n\n&lt;iframe id="i" height="80"&gt;&lt;/iframe&gt;\n\n&lt;script&gt;t.onkeyup()&lt;/script&gt;\n&lt;/div&gt;</code></pre>\r\n</div>\r\n</div>\r\n</p>\n<p>You should see <code>Hello, true XHTML. Nice to meet you!</code> below textarea.</p>\n<p>For incapable browsers you can copy content of the textarea and save it as a file with <code>.xhtml</code> (or <code>.xht</code>) extension (<a href="https://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work?rq=1#comment44088198_70288">thanks Alek for this hint</a>).</p>\n'}, {'answer_id': 58789694, 'author': 'Mark Schultheiss', 'author_id': 125981, 'author_profile': 'https://Stackoverflow.com/users/125981', 'pm_score': 2, 'selected': False, 'text': '<p>Simply modern answer is because the tag is denoted as mandatory that way</p>\n\n<blockquote>\n  <p>Tag omission  None, both the starting and ending tag are mandatory.</p>\n</blockquote>\n\n<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script</a></p>\n'}]
['https://Stackoverflow.com/questions/69913', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10778/']