3

Possible Duplicate:
Why don't self-closing script tags work?

I've noticed that you can't slash-terminate a script tag when you specify a "src" and therefore don't require anything between the <script> and the </script>. This is the only tag I know of where you can't do that.

For example, this works:

<script type="text/javascript" src="scriptsource.js"></script>

and this doesn't

<script type="text/javascript" src="scriptsource.js" />
0

3 Answers 3

5

Because the script requires an end tag:

Start tag: required, End tag: required

http://www.w3.org/TR/html4/interact/scripts.html

Sign up to request clarification or add additional context in comments.

3 Comments

ahh, does the html4 specification supersede the xhtml spec?
@Tom the script end tag is required in all specs. Why has every single answer been down voted by someone?
cheers for the clarification, and I dunno, people too nice I guess? :P
3

Here's your answer: Why don't self-closing script tags work?

Comments

1

Is it because you have to have a closing tag?

<script type="text/javascript" src="scriptsource.js"></script>

3 Comments

Ahhh whoops. I reread the question. Disregard.
it does seem that you need a closing tag, however I'm more wondering WHY this is that case, rather than IF it is, thanks for your answer though
No problem - it seems to have been answered in the question linked by Scobal.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.