or ? [duplicate]", "text": "<blockquote>\n <p><strong>Possible Duplicate:</strong><br>Why don't self-closing script tags work? </p>\n</blockquote>\n\n\n\n<p>I just found a weired behavior with the <em>script</em> tag in HTML.</p>\n\n<p>I web server is nginx, and I used FAST CGI and PHP5. I have a page.html, which looks like this:</p>\n\n<pre class="prettyprint"><code><html>\n <body>\n <!-- <?php echo 'i am going to add php code here'; ?> -->\n <script type="text/javascript" src="./my/javascript1.js" />\n <script type="text/javascript" src="./my/javascript2.js" />\n </body>\n</html>\n</code></pre>\n\n<p>If this page is served directly from the web server, the java script works well. But if it passed to PHP5, it seems only the first java script tag is executed. But if I change the <em>script</em> block into:</p>\n\n<pre class="prettyprint"><code> <script type="text/javascript" src="./my/javascript1.js"></script>\n <script type="text/javascript" src="./my/javascript2.js"></script>\n</code></pre>\n\n<p>Everything works again. Noticed how the tags are closed? Yeah, that is why I am asking here. What is the difference? They are supposed to have the same function/meaning. Besides, the output HTML that my web browser (Chrome/IE9) received are the same, but why treated differently?</p>", "answerCount": 2, "upvoteCount": 248, "dateCreated": "2011-05-11 06:02:18", "dateModified": "2022-09-28 05:52:06", "author": { "type": "Person", "name": "David S." }, "acceptedAnswer": { "@type": "Answer", "text": "<p>The script tag needs a separate closing tag to be valid code. See http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.1</p>\n\n<p>Some browsers will accept the self closing tag, others wont, and the HTML version that you are using also affects the result. There are not self closing tags unless you use XHTML.</p>\n\n<p>Passing the file through the PHP engine should not change the result, but it's possible that it makes an attempt to correct the incorrect script tags. You should view the source in the browser to see if the tags has been changed.</p>", "upvoteCount": 97, "url": "https://exchangetuts.com/scriptscript-or-script-duplicate-1640049784222483#answer-1649804730659965", "dateCreated": "2022-09-27 15:52:06", "dateModified": "2022-09-28 05:52:06", "author": { "type": "Person", "name": "Guffa" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "<p>The <code>script</code> tag is required to have a closing tag, even if it uses the <code>src</code> attribute. Avoiding it causes undesired behaviours. </p>", "upvoteCount": 45, "url": "https://exchangetuts.com/scriptscript-or-script-duplicate-1640049784222483#answer-1649804730663751", "dateCreated": "2022-09-26 15:52:06", "dateModified": "2022-09-28 03:52:06", "author": { "type": "Person", "name": "Headshota" } } ] } }