I'm using Custom Labels for a specific message and I'd like to insert a link into that message, e.g., <a href="http://my.domain.com">Go here to login</a>.

I tried this using entity characters for rending the HTML, but that just renders it as a full string:

        <value>You must agree to the terms of use and privacy notice below. &lt;a href='http://my.domain.com'&gt;Go here to login&lt;/a&gt;</value>

Can HTML markup be added to Custom Labels?


In Aura, you can do this via aura:unescapedHtml. This will render the text as is. Obviously, make sure you don't allow any unsafe HTML in there, because it could be a security risk. As long as the text is static, this is probably acceptable.

<aura:unescapedHtml value="{!$Label.c.Legal_Disclaimer_Text}" />

In general, you can have HTML in labels, but most language features (e.g. Visualforce) will take steps to automatically encode HTML as HTML entities to avoid injection attacks. Developers must always take specific actions in order to override this behavior.

  • Wow, very cool. Thanks! – Matt Smith Aug 29 '19 at 14:46

Also in LWC you can use lightning-formatted-rich-text . For example:

<lightning-formatted-rich-text value={label.myLabelWithHTML}></lightning-formatted-rich-text>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.