skip to Main Content

I have an index.html and a stylesheet CSS file which I want to use with the index.html.
The index.html references the stylesheet with:

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

However this only works for the URL that includes index.html in it:

HTTP://server/system/webdev/proj/index.html

When I try the default URL without index.html, I get a 404 and it’s looking for the stylesheet inside of the webdev folder:

HTTP://server/system/webdev/proj

How can I make it work for both URLs?

Edit:
it does work for URL: HTTP://server/system/webdev/proj/ with ending /

Can I make it work for the URL without the ending / as well as the others?

2

Answers


  1. ./ add this.

    ./ in the href attribute specifies the current directory, which means the browser will look for the stylesheet in the same directory as the index.html file

    Login or Signup to reply.
  2. It’s generally a good idea to reference style sheets (and other external resources) with the full absolute URL. That way the relationship between the HTML file and the style sheet become irrelevant:

    <link rel="stylesheet" href="HTTP://server/system/webdev/proj/stylesheet.css">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search