开发者

How to specify a standard path (location) for stylesheets

开发者 https://www.devze.com 2023-04-02 01:29 出处:网络
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 loc开发者_运维知识库ation of PHP includes files) such that

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 loc开发者_运维知识库ation 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


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


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>.

0

精彩评论

暂无评论...
验证码 换一张
取 消