html - Javascript syntax <script > VS <script><script> - the weirdest thing - Stack Ov

DuplicateWhy don’t self-closing script tags work?I'm writing an ASP page, which have some Javascri

Duplicate

Why don’t self-closing script tags work?

I'm writing an ASP page, which have some Javascript code in JS file for client-side authentication.

While using this code prevented from my server-side code from working:

<script src="../../JavaScript/BaseJS.js" type="text/javascript" defer="defer" />

This code somehow worked:

<script src="../../JavaScript/BaseJS.js" type="text/javascript" defer="defer"></script>

Duplicate

Why don’t self-closing script tags work?

I'm writing an ASP page, which have some Javascript code in JS file for client-side authentication.

While using this code prevented from my server-side code from working:

<script src="../../JavaScript/BaseJS.js" type="text/javascript" defer="defer" />

This code somehow worked:

<script src="../../JavaScript/BaseJS.js" type="text/javascript" defer="defer"></script>
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Feb 22, 2009 at 11:41 Oz RadianoOz Radiano 7892 gold badges11 silver badges30 bronze badges 1
  • this is part of the standard, script tags cannot be self closed. – DevelopingChris Commented Feb 27, 2009 at 2:00
Add a ment  | 

3 Answers 3

Reset to default 14

The HTML4.01 manual section defining the SCRIPT element, states:

18.2.1 The SCRIPT element

...

Start tag: required, End tag: required

Am I right in saying you're testing with IE? This is a known bug. (I'm sure there are lots of other pages referring to it too.)

EDIT: In fact, there's another Stack Overflow question about this too.

<script> can only self-close in XHTML, not HTML.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744905016a4600202.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信