Linking to an external css file

ぐ巨炮叔叔 提交于 2019-12-06 12:23:03

It's dependent on your file structure. Conventionally, if you keep .html files in the root directory, you'd keep style files (.css) in a directory labeled css so your structure would like

/-
 - /img
 - /css
 | --- style.css
 | --- printstyle.css
 - index.html

which means your tag line would read

<link rel="stylesheet" type="text/css" media="screen" href="./css/styles.css">
<link rel="stylesheet" type="text/css" media="screen" href="./css/printstyles.css">

Please note the "./" preceding the directory name. This means it's a relative location and is needed if you're reading your .html files locally (using file:/// instead of serving them via a local server as I imagine you are).

Given the example you've posted there, the HTML file and style sheets should reside in the same directory, e.g. Somefolder/index.html and Somefolder/styles.css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!