Possible Duplicate:
Should I include type=“text/javascript” in my SCRIPT tags?
I was writing HTML and found that even if the type in the script tag is not set to javascript, the javascript code in the tag can still be evaluated.
so I was just wondering what the difference is between the script tag with type and one without?
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
:
The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a valid MIME type. The charset parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".
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