Anchors must have content and the content must be accessible by a screen reader. (Web:S6827)

<!-- no warning but ugly -->
<a th:href="${ price.provider.path }">[[${ price.provider.name }]]</a>
<a th:href="${ price.provider.path }">[[#{ price.provider.name }]]</a>

<!-- raises a warning -->
<a th:href="${ price.provider.path }" th:text="${ price.provider.name }"></a>
<a th:href="${ price.provider.path }" th:text="#{ price.provider.name }"></a>

OS
Windows 11 Pro
Version 23H2
OS build 22631.3296
Windows Feature Experience Pack 1000.22687.1000.0

IDE
Spring Tool Suite 4
Version: 4.22.0.RELEASE
Build Id: 202403071427
Revision: 44291b464093d161f115d8e16059e5272ed3c81d

Templating engine
thymeleaf 3.1.2.RELEASE
https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring6

Java
openjdk version “17.0.7” 2023-04-18
OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

SonarLint
SonarLint for Eclipse 10.0.1.81733 org.sonarlint.eclipse.feature.feature.group

P.S.
I had to type in rule ID because it’s not available anywhere for copy/paste and that was unpleasant job. :cry:

Hello @H.Lo,

Thank you for your feedback.

You’re absolutely correct, this is a false positive and the issue should not trigger in your case. Happy to read that you found a workaround. I’ve created this ticket to address this issue.

Eric.

1 Like

Hi @eric.morand!

There are many HTML elements that produce the same kind of warning, for example H1, H2, LI (when A element is inside LI element).

Should I create a report for each of them separately or is this one enough?

BR,
Hrvoje

1 Like

Dear @H.Lo ,

We’ll take care of the other faulty elements too, you don’t need to open an issue for each of them. We need to ensure that every Thymeleaf custom attribute that maps to an element content is recognized as such by the analyzer. This will apply to all kinds of elements and, since the analyzer already supports nested contents, it will also fix the issues that you encounter with anchors nested into list items.

Eric.