I’m trying to create a link in markdown or HTML syntax rendered in an Anvil richtext field, that will open in a new browser tab.
I’ve tried adding variations of target=“_blank” to my markdown link and also trying straight HTML, neither seems to render/work properly on Anvil. I am also using anvil-extras if that adds any complications…
you can use a link component and set the url property this will open a new page, you can add your link component to a slot in your rich text component (see docs)
The rich text component works with a “safe” subset of HTML. That subset often prevents things that seem like they should be supported (e.g. changing color). You might have run up against that.
An alternative, if you control the contents you’re putting into the rich text component, is to use an HTML component instead that supports the full range of HTML. That isn’t available on the IDE list of components, but you can create it in code. This shows an example: Anvil | Login
Don’t use that if any of the HTML might be provided by users, since that opens you up to XSS attacks.