My CSS won't link to my HTML file

2020-04-21 07:08发布

I am trying to build a simple website in Sublime Text Editor 2, however, my CSS file won't link to my HTML file and therefore printing plain text. My HTML code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/       xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Christopher Olson</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,600,700" rel="stylesheet" />

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

As far as I know, the last line is supposed to link the CSS file.

This is part of the CSS that I have:

body, input, textarea
{
    font-family: 'Open Sans', sans-serif;
    line-height: 1.85em;
    color: #888;
    font-weight: 300;
}

Any ideas to fix? Please help

EDIT: I have the tags, I just ran out of room to post it

5条回答
Rolldiameter
2楼-- · 2020-04-21 07:36

I think your href is wrong

You can tried using a absolute url just like

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

You can download a very nice plugin for firefox called "firebug" it show you when some resource can't be reach

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-04-21 07:38

Your path your CSS file is probably wrong. If you're sane your CSS directory is in the webroot so your <link> should probably look like this:

<link rel="stylesheet" href="/css/style.css" />
查看更多
Bombasti
4楼-- · 2020-04-21 07:40

The link to your css files will be relative to the location of your html file. If both are int the same directory, then just include the name of the css file, if it is in a folder named "css" and that folder is in the same directory as your html file then you do "css/"

查看更多
Viruses.
5楼-- · 2020-04-21 07:49

It will 100% work if your "call" link is placed within the html file. I'm having the same issue, my only work around is to include the call links in both the .html and .css ball ache, but it works

查看更多
看我几分像从前
6楼-- · 2020-04-21 07:59

Definitely is your link's href incorrect.

查看更多
登录 后发表回答