The UA behavior limits the desired call by being more or less conformant
to the CSS2 spec; given a conformant UA, the CSS2 spec explicitly limits
the call in various ways.  One such way is in that attribute values may
not be referred to by other elements of the selector (the pseudo-element,
e.g., :before, is the selector in this case, and "content: X" is an
element, i.e., more properly, property, of the selector--or that's my
fragile interpretation of the spec).  So no, I didn't mean to suggest that

        content: url(attr(X))

would work.  I hadn't even considered nesting the properties, frankly.

Taking the simple case (I'll belabor the "external (graphic) _entity_"
[emphasis mine] case later), and noting that I reformulated the question
to read "call an external (graphic) entity from an attribute value with
CSS", a CSS style file containing

p#p1:before { content: url("bigfish1.png") }
p#p2:before { content: attr(class);
                display: inline;

will render this xhtml document (between cut lines):

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
  <title>This is a test document</title>
  <meta name="GENERATOR" content="amaya V4.3" />
http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link href="test.css" rel="stylesheet" type="text/css" />

<body xml:lang="en" lang="en">

<div id="div1" onmouseover="document.bgColor='turquoise'">
<h1 id="testh1">This is a test document (H1)</h1>

<p id="p1">This is the first paragraph of the test document.</p>

<p id="p2" class="&mdash;">And this is the second paragraph of the test

with the image from the file bigfish1.png before the first paragraph and
an em dash before the second (in the conforming-to-the-case UA Netscape

[Sorry about the debris in the test file.]

I think that demonstrates that calling a _character_ entity (which is a
type of external graphic entity) with the attr(X) property of the
pseudo-selector :before 'works', in the limited sense of the test case, as
well as demonstrating that calling a external graphic with the content
property of :before 'works'.

As for calling "an external (graphic) entity [etc.]" (the more difficult
case I said earlier I'd discuss later [yes, I think I'm amusing
sometimes]), I don't really have time to put all those pieces together
right now, nor am I entirely sure without putting the pieces together that
what I have in mind will work with existing UAs, but I think defining the
entity in an HTML catalog file, or using a local customized xhtml DTD,
might work.  It may even be feasible to define a system identifier for the
entity in the doctype declaration of the xml test file included above.

In any case, I thought I'd addressed the purpose of the question, if not
the letter of it...after all, it seems to me that, specialized jargon
aside, the easy answer to the question is that CSS isn't needed, since a
simple "href=image.file" in the xhtml file will call an external graphic
'entity' with the href attribute.

In any other case, I think it's quite possible I misunderstood the
question, or interpreted it too generously...I certainly wondered if I
hadn't done one of those two, and my expertise on such questions is


On Tue, 13 Mar 2001, Sebastian Rahtz wrote:

> ERIC Lawson - x52010 writes:
>  > > Is there any way to call an external (graphic) entity as an attribute
>  > > value in CSS? I've seen it as an XSLT transformation in Sebastian
>  > > ....
>  >
>  > There is such a way, with limitations in CSS (also UA behavior); see
>  >
>  >
>  >
>  > and especially with reference to <uri> and attr(X) in
>  >
>  >
> are you suggesting something like
>  content: uri(attr(@figure))
> ? does that work?
> I spent an afternoon trying to make some combination of this work, and
> failed dismally. if you have a working example, I'd love to see it.
> of course, if the file is also an *entity reference* (I use an extra
> attribute to make it a straight filename), it gets even worse.
> sebastian


James Eric Lawson
Research Publications Editor III
National Simulation Resource

[log in to unmask]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Nothing can exceed the vanity of our existence but the folly of our
pursuits.  -- Oliver Goldsmith