Bill
Bill

Reputation: 571

How to specify a standard path (location) for stylesheets

Is there a way to specify a standard path for stylesheets (analogous to the "include_path" directive in the php.ini file that specifies the location of PHP includes files) such that you only need to specify the unqualified stylesheet filename in the href value of the link element? Example, just be able to write:

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

in all files, regardless of their location on the website, without having to worry about where the main.css file is located?

Thank you

Upvotes: 1

Views: 595

Answers (2)

nobody
nobody

Reputation: 10645

Start your path with a / and it will be interpreted relative to the root of your website and will work on any file regardless of its location:

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

or if main.css is not in root:

<link rel="stylesheet" href="/some_folder/main.css" />

Upvotes: 5

feeela
feeela

Reputation: 29932

Use the HTML-base-tag:

<base href="http://your.domain/and/path/here/" />

Now, all your links will start at that position, even URL's inside a <LINK>.

Upvotes: 2

Related Questions