样式表链接失败HTML/CSS [英] Stylesheet link failure HTML/CSS

查看:37
本文介绍了样式表链接失败HTML/CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究带有HTML和外部CSS文件的项目.当我在Mac上的Adobe Dreamweaver上进行链接时,该链接在学校工作正常,但我通过保管箱将两个文件发送回了家,而CSS似乎未与html文件链接.我相信我拥有正确的文件路径和所有内容,但只是要确保:

I've been working on a project with a HTML and an external CSS file. The link worked fine at school when i was doing it on adobe dreamweaver on a mac, but i sent both files home via dropbox, and the css doesnt seem to link with the html file. I believe i've got the file paths and everything right, but just to make sure:

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

我还尝试从文件目录中删除"Desktop/"位,但仍然无法正常工作.我的索引文件和CSS文件都在我的桌面上.我正在使用Windows.相同的代码在学校工作,因此我认为这可能与文件位置有关.请帮忙预先感谢

i also tried removing the "Desktop/" bit from the file directory, but it still didnt work. My Index file and Css file are both on my desktop. I am using windows. The same code worked at school, so i believe it might be something to do with with file location. please help Thanks in advance

推荐答案

链接是这样的,

比方说,您的html文件位于名为"xyz"的文件夹中.现在,当链接到CSS时,该地址与html文件的位置有关.因此,如果您提到

Let's say your html file is in a folder named "xyz". Now when linking to css, the address is related to your html file's location. So if you mentioned

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

它将假定css文件与html位于同一文件夹中,而如果将其链接为

it would assume the css file is in the same folder as your html, while if you linked it as

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

假定xyz文件夹中有一个名为Desktop的文件夹,而您的css文件可能存储在Desktop中.

it would assume there is a folder named Desktop inside the folder xyz, and your css file is probably stored in Desktop.

现在我假设您只是将HTML和CSS都直接直接放在了桌面上,这不是一个好习惯,因为您可能还会将这些文件也放回学校.因此,我建议您将它们都放在一个文件夹中,然后使用

Now im assuming you've simply placed both your html and css on your desktop directly, this is not good practice as you're probably going to move these files back to school as well. Hence I'd recommend you to place both in a folder and then link to your css with

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

并且不要忘记注意大写,是的html不区分大小写,但是在链接外部文件时,大写确实很重要.

and dont forget to pay attention to capitalization, yes html is non case sensitive but when it comes to linking external files, capitalization does matter.

这篇关于样式表链接失败HTML/CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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