is type =" text / css"必须在< link>标签? [英] Is type="text/css" necessary in a <link> tag?

查看:134
本文介绍了is type =" text / css"必须在< link>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否需要使用< link rel =stylesheettype =text / csshref = ...> over < link rel =stylesheethref = ...> rel =stylesheet标记了它是样式表的信息 - 因此 text / css



HTML使用的唯一样式表格式是CSS,因此 text / css 'say'到浏览器?有些网站似乎添加了 type =text / css属性( http:// www .jquery.com / ),而其他则不会( http://www.youtube.com/ ) 。



那么,在 type =text / css >< link rel =stylesheet> 元素,是否需要包含它?

解决方案

HTML5规范并不要求这样做,但对于较旧版本的HTML则需要。



Html 4 W3.org规格 / p>

http ://www.w3.org/TR/html40/struct/links.html#edef-LINK
http://www.w3.org/TR/html40/present/styles.html



类型代表样式表的MIME类型。我看到的唯一支持的值是Text / CSS,这可能是为什么HTML5已经删除它。我想象他们有它的早期版本允许未来的扩展可能性从来没有发生。



使用HTML5而不指定类型,我运行到目前为止没有兼容性问题即使测试旧版本的IE。


I was wondering whether or not it is necessary to use <link rel="stylesheet" type="text/css" href=...> over <link rel="stylesheet" href=...>. The rel="stylesheet" marks the information that it is a stylesheet - so text/css doesn't actually add anything as far as I'm concerned.

The only stylesheet format used by HTML is CSS anyway, so what does text/css 'say' to the browser? Some websites seem to add the type="text/css" attribute (http://www.jquery.com/), whilst other ones don't (http://www.youtube.com/).

So, what is the use of type="text/css" in a <link rel="stylesheet"> element, and is it necessary to include it?

解决方案

It's not required with the HTML5 spec, but for older versions of HTML is it required.

Html 4 W3.org spec

http://www.w3.org/TR/html40/struct/links.html#edef-LINK http://www.w3.org/TR/html40/present/styles.html

Type stands for The MIME type of the style sheet. The only supported value I have ever seen is Text/CSS, which is probably why HTML5 has dropped it. I imagine they had it for earlier versions to allow future expansion possibilities which never happened.

Using HTML5 and not specifying the type, I have run so far into no problems with compatibility even when testing older versions of IE.

这篇关于is type =&quot; text / css&quot;必须在&lt; link&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆