Css Content, Attr and Url in the same sentence

It’s neither a bug nor a mistake. The currently supported syntax (CSS2.1) for content is:

content: normal | none | 
         [ <string> | <uri> | <counter> | attr() |
           open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit

I.e.:

  • The literal normal, none or inherit

  • Or any number of these in succession:

    • a string – "hello"
    • a (constant) URI – url("image.jpg")
    • a counter – counter(section)
    • an attribute – attr(id)
    • open-quote, close-quote, no-open-quote, no-close-quote

The specs don’t allow for them to be “nested”, they can only follow each other, e.g.:

content: "Photo: " url("../Img/Photo.jpg") attr(id);
/* Which is not what you want */

The current CSS3 drafts don’t allow for it either. Possibly – if it’s been discussed – because most use cases would have little to do with presentation and more to do with actual content.

Leave a Comment