Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  5] [ 3]  / answers: 1 / hits: 139094  / 11 Years ago, wed, december 25, 2013, 12:00:00

I was just wondering, what is the difference between



<script>


and



<script type = 'text/javascript'>


Is it different for different webservers?



For example,(I know it's incorrect to provide a link from w3schools, but look)



http://www.w3schools.com/js/tryit.asp?filename=tryjs_myfirst



Using chrome, I visited w3schools and I realised that the <script> tag is all I need.



However, when I did an offline javascript test, i realised that i need the



<script type = 'text/javascript'>


tag. Why is this so?


More From » html

 Answers
11

In HTML 4, the type attribute is required. In my experience, all
browsers will default to text/javascript if it is absent, but that
behaviour is not defined anywhere. While you can in theory leave it
out and assume it will be interpreted as JavaScript, it's invalid
HTML, so why not add it.



In HTML 5, the type attribute is optional and defaults to
text/javascript




Use <script type=text/javascript> or simply <script> (if omitted, the type is the same). Do not use <script language=JavaScript>; the language attribute is deprecated



Ref :

http://social.msdn.microsoft.com/Forums/vstudio/en-US/65aaf5f3-09db-4f7e-a32d-d53e9720ad4c/script-languagejavascript-or-script-typetextjavascript-?forum=netfxjscript

and

Difference between <script> tag with type and <script> without type?



Do you need type attribute at all?



I am using HTML5- No



I am not using HTML5 - Yes


[#73554] Monday, December 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reed

Total Points: 725
Total Questions: 85
Total Answers: 89

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
;