html没有链接css [英] html not linking css

查看:94
本文介绍了html没有链接css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了链接html和Css的问题,并且不知道为什么。我正在做的就像书和教程所说的那样。但是,我没有做css的外部配置。

I'm having an issue with linking html and Css and have no idea why. I'm doing everything like the book and tutorials says. However, I'm not getting to do the external configuration of css.

这是代码(只是测试):

This is the code(just a test):

<!DOCTYPE html>
<html lang = "eng">
    <head>
        <meta name="viewport" content="width=device-width; initial-scale=1.0">

        <title>title</title>
        <meta name="description" content="">
        <meta name="keywords" content="">

        <link rel="stylesheets" type="text/css" href="/styles.css">
    </head>

    <body>
        <h1>test</h1>
    </body>
</html>

和CSS:

body {
    background-color:#CCCCCC;
}

h1 {
    color:#0000EE;
}

也许我想念一些东西,因为当我做内部css时(在我的html代码中)有)它没问题,网络浏览器能够读取它。似乎html没有与css链接,但它甚至在同一个文件夹中,所以路径不应该是问题。

Maybe I miss something, because when I do internal css (within my html code with ) it goes ok and the web browser is able to read that. It seems like the html is not linked with css, but it's even on the same folder so the path shouldn't be the problem.

我正在使用Linux和Aptana Studio。

I'm using Linux and Aptana Studio.

过去2小时我搜索了很多,无法找到错误的位置。

I've searched a lot the last 2 hours and cannot find where the mistake is.

推荐答案

我邀请您阅读本文绝对和相对路径

然后我们传递给您的代码:

Then we pass to your code:

< ; link rel =stylesheetstype =text / csshref =/ styles.css>

应该是:

< link rel =stylesheettype =text / csshref =styles.css>

您的 styles.css 应与...在同一个文件夹中您的html文件。

Your styles.css should be in the same folder as your html file.

要验证您是否有错误,请检查浏览器的控制台,您会发现您的文件没有存在(404错误)。

To verify that you have an error , check Console of your browser,you will be noticed that your file doesn't exist(404 error).

让你的css工作的另一种方法是将它集成到你的页面中而不会分离:

An other way to make your css working is to integrate it inside your page without separation:

示例:

 <style type='text/css'>

    body {
        background-color:#CCCCCC;
   }

    h1 {
        color:#0000EE;
    }
</style>

这篇关于html没有链接css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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