Textarea Link fetch style from linked page

Hello,
In a kirby textarea I inserted a link through the backend, this is how i call the textarea in the php file

<p class="textblockLesung"><?=$page->textblock()->kti() ?></p>

up until now I style the links created like so

.textblockLesung a{
    background-color: <?= $page->color() ?>;
}

but now the link has the background-color assigned to the page that were on, how can I change it so that the link gets the background-color of the page it is linking to?
All the pages crossreferencing are $pages->listed() and all of them have a color assigned through the backend.
Thankful for any tips or ideas on how to go about this!

I think your best bet is to handle this in a custom version of the link kirbytag, where you have access to the tag value (a page uuid), and then you can take it from there. Then you can add a proper class to the a tag and you don’t have to have an ugly mix of CSS and PHP.

the links are spread out through a running text, so do you mean I would create textfield linkfield textfield linkfield (…) in the backend?

No, that’s not what I mean.

You wrote, you are using a textarea field. In a textarea field, links are added through kirbytags:

(link: somepageuuid)

These can be modified, see KirbyTags | Kirby CMS

But maybe you are not using a textarea field but blocks?

ah! yes I am using a textarea field (but thinking about blocks atm if thats easier to deal with?)

For your use case, not really. As I wrote above, with a modified Kirbytag, this is pretty easy to solve.

yes i’ve realized as soon as you said it sorry (i think I had a not seeing the forest bc of all the trees moment)
i’m just going to implement images through the files option with the textarea then.
thank you