0

Let's say I have an XML file:

<X attr="1"> something</X>
<Y> something else </Y>

How can I do something that would be equivalent to:

Y:before
{
   content:attr(1);
}

in CSS?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
czarniecki
  • 63
  • 5
  • 1
    CSS works the same in XML as it does in HTML, and there's no way for `attr` to get the value of anything other than the selected element (or pseudo-element). – Heretic Monkey Oct 16 '21 at 20:53
  • 1
    Does this answer your question? [using attribute value of a parent in a child using CSS3 attr function](https://stackoverflow.com/questions/42034739/using-attribute-value-of-a-parent-in-a-child-using-css3-attr-function) – Heretic Monkey Oct 16 '21 at 20:56
  • 1
    Using the technique in the linked question, you could possibly use CSS custom properties to do something similar, but I'm not sure it would work without the parent/child relationship. You'd have to play around with ordering of CSS statements. – Heretic Monkey Oct 16 '21 at 20:58
  • 1
    @HereticMonkey in my case, there's no parent/child relationship. Guess i'll do without that attribute. Thanks though – czarniecki Oct 16 '21 at 21:07

0 Answers0