Topic: How would I be able to do this in CSS?

background-image: url('http://domain.tld/attr(title).png');

where the title attribute says "image" so the actual URL should be http://domain.tld/image.png. This is bugging me so much... sad

2

Re: How would I be able to do this in CSS?

If you mean you want to the name of the image file to vary then the answer is you can't, css has no support for variables in style declarations whatsoever. The only way to do it is to generate the css dynamically.

Re: How would I be able to do this in CSS?

I will dynamically make the title element to the specified image name and via css retrieve the content. The attr(attribute) function can retrieve the contents of specified attribute; it's just that I don't know how to do so in my example. More concise:

<style type="text/css">
#test::after {
content: url('http://www.yahoo.com/attr(test).png')
}
</style>

<div id="test" title="main">
...
</div>

Doing this yiels no output.

Re: How would I be able to do this in CSS?

What I'd advise you to do, is to reference a PHP script as your stylesheet instead of a static CSS file. With some mod_rewrite magic, you could even name the file '.css'. Then you can just do whatever you want in the PHP code as long as you do 'header("Content-Type: text/css; charset=iso-8859-1");' and only output CSS code from the file.