Forum Moderators: open

Message Too Old, No Replies

Proper way to close a JavaScript inclusion tag in head of document?

         

JAB Creations

10:24 am on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it...
<script src="..." type="text/javascript"></script>

or ...

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

?

Both seem to validate (if I remember correctly) (xhtml 1.1).

BlobFisk

10:32 am on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would be inclined to say:

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

There can be content between the script tags and there is both an opening and closing tag available here.

bird

10:45 am on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



While both variants are technically valid, using an explicit closing tag is safer. Some (arguably broken) spiders might not understand the /> syntax for empty tags. They will get confused if they don't find a seperate </script>.

g1smd

3:59 pm on Sep 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



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

JAB Creations

8:25 am on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's what I've been using and leaning towards but it didn't cross my mind until late if I might be doing it incorrectly. :)