For <script>
HTML tags, what is the technical difference between lang=Javascript
and type=text/javascript
?
I usually use both, because I've always assumed that older browsers need one or the other.
The type attribute specifies the type of the script. The type attribute identifies the content between the <script> and </script> tags.
The HTML lang attribute is used to identify the language of text content on the web. This information helps search engines return language specific results, and it is also used by screen readers that switch language profiles to provide the correct accent and pronunciation.
Attributes: Many attribute associated with script tag. async: It is used to specify the script is executed asynchronously. charset: It is used to specify the character encoding used in an external script file.
The lang (or sometimes the xml:lang ) attribute specifies the natural language of the content of a web page. An attribute on the html tag sets the language for all the text on the page.
The OP specifically said "lang" not "language". The much older "language" tag would have been Javascript or VBScript.
But the current and seemingly valid "lang" tag is actually which written language like English, Spanish, Japanese. Microsoft's Visual Studio provides a dropdown list for the values for "lang" and they are all like en-us, fr, ja, etc.. for English US, French, Japanese, etc...
I'm thinking there could be valid reasons for using this tag if you have a complex multilingual setup - maybe there's a content mgmt system that could support this and then deliver the proper javascript file - like jQuery control resources?
Per the HTML 4.01 Spec:
type: This attribute specifies the scripting language of the element's contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript"). Authors must supply a value for this attribute. There is no default value for this attribute.
language: Deprecated. This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With