根据我的外观,我看到包含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=""/>
Run Code Online (Sandbox Code Playgroud)
他们都这样做吗?
其中一个是正确的方法吗?
全部正确.该type属性不是必需的 - 它只是浏览器的提示,但可以省略.该media属性告诉浏览器何时应该使用CSS文件.例如,如果您指定media="print"CSS文件将仅在打印页面时使用(例如,尝试打印维基百科页面).
通常这种变体在大多数情况下都很好:
<link rel="stylesheet" type="text/css" href="..."/>
Run Code Online (Sandbox Code Playgroud)