What is the difference in different ways of defining a script?

What is the difference in different ways of defining a script?

The ways I'm talking about are

  • <script>....</script>
  • <script language="javascript">.....</script>
  • <script type="text/javascript">...........</script>

So how do they all do the same thing as the other?

+3
source share
3 answers

According to the w3c spec , an attribute is required typeand defines the script language, while an attribute language(which does more or less the same) is deprecated in favor type, so you should use the attribute type.

+4
source

<script language="javascript">

HTML 3.2 First Attempt

<script type="text/javascript">

HTML 4.x and XHTML 1.x - using MIME types for everything. This is the current standard. Use this.

<script>

HTML 5 () - ", , , , "

+3

Source: https://habr.com/ru/post/1751869/


All Articles