JS Script Declaration Syntax

I'm not sure what is the difference between opening a JS script with

<SCRIPT language='JavaScript'>

or using:

<SCRIPT type="text/JavaScript">

If JavaScript is always quoted (either with "" or c ''), or is that not important?

Thanks for any clarification on this topic!

+3
source share
7 answers

The language attribute was used in HTML 3.2. Introduced type HTML 4.0 (which is consistent with other elements related to external media, for example <style>), and required it. He also deprecated language.

Use type . Do not use language .

HTML ( XHTML) , ( , , ).

+16

Javascript Code Conventions Javascript:

JavaScript

JavaScript in .js .

JavaScript HTML, . HTML .

< script src= filename.js > , . , script . . , script, MIME .

+2

- , mimetype /javascript, .

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

, .

<style type="text/css">

- - ( ) .

+1

JavaScript type language:

<script src="script.js" />

, , . script - type = "text/javascript".

Edit:

, , Yahoo! JavaScript ( , ) -.

, .

Google - , -. ( W3C, JavaScript ). - - , i.

. , :)

+1

W3 HTML 4.01 , . langage , , , Microsoft Netscape.

, XHTML 1.0 ( ). , html ( HTML 4.01, XHTML 1.0).

0

:

<script language="javascript" type="text/javascript">
-2

("). apostraphes (').

Change . The opinion is made, it seems, here, my bad. Single quotes are technically legal, but, in my experience, they tend to lead to more problems than double quotes (they often occur among attribute values ​​among other things), so I always recommend sticking to the latter. Your mileage may vary, though!

-3
source

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


All Articles