包含CSS文件的语法正确吗? [英] Correct syntax for include css file?

查看:52
本文介绍了包含CSS文件的语法正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的位置,我会看到以不同的方式包含CSS。

Depending on where I look, I see different way to include css.

示例

<link rel="stylesheet" type="text/css" media="screen, projection" href=""/>
<link rel="stylesheet" type="text/css" media="all"                href=""/>
<link rel="stylesheet" type="text/css" media="screen"             href=""/>
<link rel="stylesheet"                                            href=""/>

它们是否都一样?

其中之一是正确的方法吗?

Is one of them the correct way?

推荐答案

都正确。
不需要 type 属性-它只是浏览器的提示,但可以省略。
media 属性告诉浏览器何时应使用CSS文件。例如,如果指定 media = print ,则仅在打印页面时使用CSS文件(例如,尝试打印Wikipedia页面)。

All are correct. The type attribute is not required - it is just a hint for browsers but can be omitted. The media attribute tells the browser when the CSS file should be used. For example, if you specify media="print" the CSS file will only get used when printing the page (try to print a Wikipedia page, for example).

通常,此变体在大多数情况下都可以使用:

Generally this variant is fine in most situations:

<link rel="stylesheet" type="text/css" href="..."/>

这篇关于包含CSS文件的语法正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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