Possible Duplicate:
HTML5 <script> declarations
I've heard a few people say that you don't need to specify a type="text/javascript"
in a <script>
tag, as this is the default type.
Is there any downside if I open my script tags as <script>
instead of the more verbose <script type="text/javascript">
?
In HTML4 the type
attribute is required:
http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.1
In HTML5 it is not.
http://dev.w3.org/html5/markup/script.html
If you are going to use HTML4, then good practice certainly includes adhering to its specifications. If you're using HTML5, then it's pretty clear that <script>
without a type
is text/javascript
, so you can safely omit it.
Yes! You absolutely can omit the type. Make sure your document type is HTML5 if you care for validity.
<!doctype html>
It will work just as fine though with any browser you can think of.
It won't be considered "good practice" to break the specifications if you're not using HTML5 though :)
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