user2095044
user2095044

Reputation: 233

Stylesheet link failure HTML/CSS

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" />

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

Upvotes: 1

Views: 6703

Answers (4)

Shail
Shail

Reputation: 3649

The problem is with your file location .
If you are using Dreamweaver or any other code editor, simply browse to the path of the file to insert it in link href attribute, rather than manually entering the path .

Upvotes: 0

TDsouza
TDsouza

Reputation: 938

This is how linking works,

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" />

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" />

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

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" />

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.

Upvotes: 3

Kevin Bowersox
Kevin Bowersox

Reputation: 94499

Your directory structure should look as follows:

  Root Directory 
  | 
  |-page.html 
  |-Desktop
      |-StyleSheet.css

If it does not you need to modify your directory structure or change the href attribute on the link tag

Upvotes: 2

pfried
pfried

Reputation: 5089

If it is in the same directory simply set the path to href="Stylesheet.css"

Upvotes: 1

Related Questions