Skip to main content
Level 2
May 5, 2026
Question

Need to create aria-label for RTE link plugin

  • May 5, 2026
  • 2 replies
  • 46 views

I am trying to add aria-label to rte link plugin. I have added it but its getting stripped even after adding the value to the xss protection config. How to solve this.

2 replies

Level 4
May 12, 2026

Hi ​@lak_priya ,


This is a common ADA/accessibility issue with AEM’s RTE link plugin and the XSS protection stripping is exactly the right place to look. Let me walk through the full fix.

 

The aria-label attribute gets stripped because AEM’s AntiSamy XSS protection policy doesn’t include aria-label in its allowlist for anchor tags by default. Even if you’ve added it, the path matters you need to make sure you’re editing the correct config file and that it’s being picked up by your environment.
In AEM Cloud the XSS protection config lives in your ui.config module under /apps/your-project/config/com.adobe.granite.xss.impl.XSSFilterImpl.xml or the equivalent OSGi config JSON. Inside that config you need to find the anchor tag definition and explicitly add aria-label to the allowed attributes list.

 

The config entry for the anchor tag should look something like this find the existing anchor element definition and add aria-label alongside the other permitted attributes like href, target, and title.

 

Beyond the XSS config there’s a second place you need to check. The RTE link plugin itself has its own htmlRules configuration in your RTE dialog or RTE configuration node under /apps. Look for the htmlRules/elements/a node and make sure aria-label is listed under the supportedAttributes or similar property. If the RTE’s own HTML rules don’t allow the attribute it will strip it before XSS protection even sees it.

 

So the full fix is two places XSS AntiSamy config to allow the attribute through the output filter, and the RTE htmlRules config to allow it through the editor itself. Missing either one will result in the attribute being stripped even if the other is configured correctly.

 

After making both changes redeploy your config bundle and test in author mode with the browser dev tools to confirm aria-label is persisting on the saved anchor tag in the JCR.

lak_priyaAuthor
Level 2
May 21, 2026

Hi ​@akhil_merupula , 

I have defined the html rules but still aria-label is not getting display. I get multiple ways of writing this HTML rules, do you have a sample exact code to add them.

Level 4
May 22, 2026

Hi ​@lak_priya,


Here is the exact config you need for both places.

 

Place 1 XSS AntiSamy config. Find your com.adobe.granite.xss.impl.XSSFilterImpl.xml file and locate the anchor tag element definition. Add aria-label to the attributes list like this:

 

<element name="a">
    <attribute name="href"/>
    <attribute name="target"/>
    <attribute name="title"/>
    <attribute name="aria-label"/>
</element>


Place 2 RTE htmlRules config. In your RTE configuration node under /apps/your-project, find or create the htmlRules node. The structure should look like this:

 

<htmlRules jcr:primaryType="nt:unstructured">
    <elements jcr:primaryType="nt:unstructured">
        <a jcr:primaryType="nt:unstructured"
            attributes="[href,target,title,aria-label]"/>
    </elements>
</htmlRules>

 

The attributes property is a multi-value string array containing all the attributes you want to allow on anchor tags in the RTE output.

 

Important things to verify after making these changes. First confirm you are editing the correct XSS config file on AEMaaCS it must be in your ui.config module, not manually edited in CRXDE, as manual CRXDE changes do not persist. Second redeploy via Cloud Manager pipeline after the change. Third test by adding a link in the RTE, saving, then checking the JCR node in CRXDE to confirm aria-label is stored on the anchor node.

 

If aria-label is in the JCR but not rendering in the browser, the issue then shifts to your HTL template needing to output it explicitly. Let me know which step it fails at and we can narrow it down further.
 

lak_priyaAuthor
Level 2
May 22, 2026

Hi ​@akhil_merupula ,

Thanks for all your input. I added them but it didnt work as expected. Then I got the latest file from libs and made all the changes done so far with the upgraded file. The new libs file already had aria-label. After that only it worked.

I appreciate your replies. !!