w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to reuse css with relative links from sub directories?

It sounds like your stylesheet may be set up incorrectly. Typically you should put your css and your images in the same parent directory. Like so:

assets > styles > styles.css
assets > images > image.jpg

That way your images will always be a relative path inside of the document matching this:

background: url(../images/image.jpg); 

You can then set an absolute path in your HTML link tag and link the current page to the stylesheet like so:

<link href="http://mysite.com/assets/styles/styles.css"
type="text/css" rel="stylesheet" />

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.