简体   繁体   中英

Why is my CSS file not linking to my HTML file?

Here is the path I am working with - /public_html/websystems/websystems.css

The HTML file I am trying to link is in the public_html directory and named index.html

The CSS file I am trying to link is in the websystems directory and named websystems.css

The contents of the files are shown in the images below.

HTML file 在此处输入图片说明

CSS file 在此处输入图片说明

Why are none of the styles I've set in my CSS file applying to my HTML file?

Thanks for your help.

Try this,

websystems/websystems.css


Note that, (taken from Quick Reminder About File Paths )

  • Is the image in the same directory as the file referencing it?
  • Is the image in a directory below ?
  • Is the image in a directory above ?

By "below" and "above", I mean subdirectories and parent directories. Relative file paths give us a way to travel in both directions. Take a look at my primitive example: 在此处输入图片说明

Here is all you need to know about relative file paths:

  • Starting with "/" returns to the root directory and starts there
  • Starting with "../" moves one directory backwards and starts there
  • Starting with "../../" moves two directories backwards and starts there (and so on...)
  • To move forward, just start with the first subdirectory and keep moving forward

Change the /websystems/websystems.css to just websystems/websystems.css and see if that works. That's a path relative to the current path of index.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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