0

I would like to do this in HTML: <a href="http://host.com/cat.png">text</a>

and in CSS: a { background-image: url(attr(href)); }

It doesn't seem to work for me. Is it even possible?

Kumar
  • 11
  • 1

1 Answers1

2

Not possible in static CSS file. However you can have dynamically generated CSS by any server side language such as PHP.

Or use Sass or LESS if you need variables in CSS.

Gurpreet Singh
  • 20,907
  • 5
  • 44
  • 60