Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying base url for css

Tags:

html

css

url

path

I had to split up a long css file. I put the smaller css files within a styles directory.

Now I have to update the the urls to go up one level with the ../ notation.

Is there anyway to specify the base URL from which to load assets like with the base tag in HTML, but with CSS?

like image 451
rhlee Avatar asked Sep 28 '10 11:09

rhlee


People also ask

How do you define base URL?

The URL found in the address bar of the front page of a website is its base URL. In other words, the common prefix found while navigating inside a given website is known as the base URL. One can select a base URL from the list of those available with help of the URL general properties page.

How do you write URL in CSS?

A string which may specify a URL or the ID of an SVG shape. If you choose to write the URL without quotes, use a backslash ( \ ) before any parentheses, whitespace characters, single quotes ( ' ) and double quotes ( " ) that are part of the URL.

What is base URL example?

A base URL is, basically, the consistent part of your web address. For example, throughout this training site, you'll note that the address section http://webtech.training.oregonstate.edu always appears in the address bar. This is the base URL.


1 Answers

No, there isn't. I suggest to place the CSS images in at least the same level as the CSS file so that you don't need to go backwards in the path. E.g. /css folder for CSS files and /css/images folder for CSS images. Then you can consistently use url('images/name.ext') for CSS images. This way you can place the root /css folder practically everywhere without fiddling with the image URL's.

like image 85
BalusC Avatar answered Sep 21 '22 18:09

BalusC