简体   繁体   English

为什么我的 CSS 文件没有链接到 VS Code 上的 HTML 文件?

[英]Why is my CSS file not linking to my HTML file on VS Code?

I'm working on VS code, and I'm having difficulty linking my style sheet to my index.html file.我正在处理 VS 代码,我很难将我的样式表链接到我的 index.html 文件。 When I look at the folder that my files are in, my css file saves as a web page-- is that typical?当我查看我的文件所在的文件夹时,我的 css 文件保存为 web 页面 - 这是典型的吗? I'm wondering if that is my problem...我想知道这是不是我的问题...

The code that I am using to link my css file to my html file is:我用来将我的 css 文件链接到我的 html 文件的代码是:

link rel="stylesheets" type="text/css" href="stylesheets.css"链接 rel="stylesheets" type="text/css" href="stylesheets.css"

The above code is wrapped in <>...but when I put it into the question, the code ends up not showing up, so that's why does are missing.上面的代码包含在 <>... 但是当我把它放到问题中时,代码最终没有显示出来,所以这就是缺少的原因。

Thank you in advance!先感谢您!

I think the problem is in the rel you should use stylesheet instead of stylesheets我认为问题在于你应该使用样式表而不是样式表

<link rel="stylesheet" href="stylesheets.css">

and make sure stylesheets file and HTML file in the folder并确保文件夹中的样式表文件和 HTML 文件

if your.css file is located in the same folder as.html file use:如果您的 .css 文件与 .html 文件位于同一文件夹中,请使用:

   <link rel="stylesheet" href="./style.css">

and if it is in the different folder use:如果它在不同的文件夹中,请使用:

   <link rel="stylesheet" href="./folderName/style.css">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM