I know that with the HTML5 doctype that "type" is optional in script tags.

<script src="file.js"></script>

instead of

<script type="text/javascript" src="file.js"></script>

since the default is javascript for the most part. My question is this: if I use an HTML5 doctype and do not include the type property, are their any browsers that would not automatically default to javascript? i.e. should I just leave it in anyway since it's not deprecated to be safe?

1 answer


Any browser that you would be interested in supporting will default to JavaScript.

Answered almost 8 years ago by Tim Hettler
  • Bit of a non-answer. Ben Borowski almost 8 years ago
  • But I think Tim is right. Browsers for a long time have defaulted to `text/javascript` if the `type` attribute was omitted (although it was strictly a reqd attribute), HTML5 just makes it _officially_ optional - it is no longer a required attribute and will _officially_ default to `text/javascript`. w3d almost 8 years ago
  • Fair enough! I think that your comment is what he was trying to say in so many words ;) Ben Borowski almost 8 years ago
  • Maybe you should have made an attempt to read those words before complaining about them. Nathan Duran almost 8 years ago
  • Just to add a link to the actual standard: http://dev.w3.org/html5/spec/Overview.html#script (HUGE page, will take some time to open and scroll down) Oskar Austegard over 7 years ago