html type="text/javascript",html - is "<script type='text/javascript'>" incorrect? - Stack Overflow

I think Brandon is (at least) partially wrong. The latest editor's draft of HTML5 (15 Aug 2011) says:

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".

So if you do not include a type attribute, the default value is "text/javascript". If that is the default value, it must be a valid MIME type.

What are the other valid MIME types? The spec doesn't seem to give an example list, but it does specify the required format when it says:

A string is a valid MIME type if it matches the media-type rule

defined in section 3.7 "Media Types" of RFC 2616

Which you can have the joy of reading here:

Edit: Quentin is right: For HTML5, there's no need to include a type attribute, assuming you're using Javascript.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值