Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between these two things

Tags:

jquery

asp.net

I have a doubt regarding this writing this below statement

  1. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/>

  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/>

Here i didn't mentioned the type in the Second Statement.But still am getting the jquery or $ symbol.Cud any explain me ?

Here i am using VS 2010.

like image 911
Hemant Kumar Avatar asked Feb 25 '23 10:02

Hemant Kumar


1 Answers

Browsers have, for many years, assumed that a script will be JavaScript unless the type attribute says otherwise. The HTML5 draft makes this explicit.

Note that the use of XML-style self closing tags is:

  • OK in XHTML 1.0/1.1 (but leaving the type attribute off is not)
  • NOT OK in HTML-Compatible XHTML 1.0 (which you need to use if you want IE8 and lower to work)
  • NOT OK in HTML 4.01
  • NOT OK in HTML5

If you are writing HTML 4.01 (which is a sensible idea for most sites as it has mature QA tools) then you should be writing:

<script type="text/javascript" 
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
</script>

If you are writing XHTML 1.0 and jumping through the hoops needed to supply it to Internet Explorer 8 and lower, then you should be using the same syntax for script elements as HTML 4.01.

If you are writing HTML5, then you may omit the type attribute, but the explicit end tag is still required.

like image 52
Quentin Avatar answered Mar 07 '23 13:03

Quentin