I am looking to allow data attr in tags with Redactor content.

What should I add to the Default config settings to allow this attr?

2 Answers 2


See this config setting: http://htmlpurifier.org/live/configdoc/plain.html#HTML.AllowedAttributes

You should be able to use it to allow data attributes.

  • Thanks Clark, I am aware of the settings, however when I try something like this "HTML.AllowedAttributes": ["img.src", "img.alt", "a.href", "*.title", "*.data"] I get an error saying Global attribute '*' is not supported in any elements. Even if i try to set the attr to an element, it still doesn't allow it Attribute 'data' in element 'a' not supported. I have also tried adding the HTML.AllowedElements setting too, to make sure the tag was allowed, but that made no difference.
    – zizther
    Sep 5, 2019 at 9:20
  • Have you tried just .data or data Sep 5, 2019 at 17:00
  • can confirm that using either ".data" or "data" will not work.
    – Chad W
    Oct 29, 2019 at 15:05
  • Was anyone able to get this to work?
    – CreateSean
    May 20, 2021 at 13:29
  • 1
    @CreateSean - craftcms.stackexchange.com/a/38833/10878 Dec 27, 2021 at 6:15

Found this, which may help someone who is smarter than I am go down a path to solve this: https://stackoverflow.com/a/29317456/584599

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.