Problem/Motivation

Field's help text allows html-tags. The list of allowed tags is hardcoded in core.

Currently allowed tags include:
<a> <b> <big> <code> <del> <em> <i> <ins> <pre> <q> <small> <span> <strong> <sub> <sup> <tt> <ol> <ul> <li> <p> <br> <img>

Issue #3353613: Allow tags details and summary in the help text instructions presented to the user below editing form field would allow also:
<details> <summary>

Some of the allowed tags (<big>) are deprecated in HTML5 and some of the others are often recommended to be avoided (<i>, <b>). Other tags may feel out of place in the context of a field's help text. Some may have accessibility implications, as the the help text is used as aria-describedby attribute for the field input as a string losing semantics.

Steps to reproduce

Edit a field in Field UI and check the list of allowed tags.

Screenshot of field help text textarea.

Proposed resolution

The list of allowed tags should be reviewed.

This is will result in a breaking change and should be implemented in the next major version.

Remaining tasks

Review the list of allowed tags.
Decide whether the allowed tags should be a setting instead of core code.

User interface changes

The tags are listed in the UI, so putting the recommended tag changes in this section.

Missing tags for help text include

WCAG 3.1.3 (AAA) Technique H40 recommended https://www.w3.org/WAI/WCAG22/Techniques/html/H40
<dl><dt><dd>

This should probably not be available for List (text) item labels

Details element, as per discussed at Accessibility office hours
<details><summary>

This should not be available for List (text) item labels

Removing tags not included in HTML5

<big>

Removing or marking tags that are not recommended to be used

<b><i>

Tags that are not HTML phrasing content

HTML5 pecification: "Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not any flow content."
https://www.w3.org/TR/2011/WD-html5-20110405/content-models.html#phrasin...

List (text) label is rendered inside <label> element.
The following should not be available for List (text) item labels, as they are flow content
<ol> <ul> <li> <p>

Adding tags that are similar to allowed tags
<svg> (since img is allowed)

Introduced terminology

API changes

Data model changes

The allowed tags between help text and field type "List (text)" should be separated lists. The scope may be wider even.

In "List (text)" the html may be inside a control element and thus not accessible where as in help text a wider range of html vvan be allowed.

Release notes snippet

Comments

simohell created an issue. See original summary.

quietone’s picture

Version: 11.3.x-dev » 11.x-dev

Hi, in Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies. Thanks.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

simohell’s picture

Title: Review allowed tags in field help text » Review allowed tags in field help text and other contexts
Issue summary: View changes

Just checked, that the allowed tags are in core the same for field's help and field type "List (text)" label. There should not be the same line of code. This needs quite a bit more thought, it seems.

kentr’s picture

Issue tags: +Accessibility

Added the accessibility tag to put it on the radar of contributors who search for that.

kentr’s picture

I think the first step is to make a list of the problematic tags.

For BC, they could initially remain as options but with a note that they are deprecated / not recommended.

simohell’s picture

Issue summary: View changes

I'm starting a preliminary list at the issue summary.
The list is incomplete, but is a starting point.

benjifisher’s picture

StatusFileSize
new13.22 KB

Usability review

We discussed this issue at #3569220: Drupal Usability Meeting 2026-02-06. That issue will have a link to a recording of the meeting.

For the record, the attendees at the usability meeting were @benjifisher, @rkoller, @simohell, and @the_g_bomb. I have given then credit on this issue.

We have two recommendations:

  1. Do not remove <a> from the list of allowed tags for labels.
  2. Do use a separate list of tags for help text, and allow additional tags such as those for definition lists and details elements.

The only usability issue we noticed is that a site builder might make the entire label a link, like "Terms of service" in this screenshot. If so, then clicking anywhere on the label triggers the link instead of selecting the list option.

Screenshot showing options "N/A" (plain text), "Terms of service" (a link), and "Anything More information on Anything" (first word is plain text, the rest is a link)

On the other hand, there are use cases for including links, say to a page of terms and conditions. Furthermore, the site builder can avoid the usability concern by including additional text outside the link, like "Anything" in the screenshot. Even if the site builder does not do that, there are other ways to select the option: click on the checkbox/radio button (not on the label text), or use keyboard navigation.

I am not sure the second point counts as a usability issue, but we think there are valid uses for additional tags in help text.

If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.

simohell’s picture

Issue summary: View changes

It looks like HTML5 definition restricts tags for List (text) item labels by disallowing flow content. Paragraphs and html-lists are flow content. This supports imo strongly separate lists for the two use cases.

simohell’s picture

MDN recommends against a-tags inside label (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/lab...), but it does not seem to be a strict violation.