0

I am trying to insert path to the image into HTML 5 attribute. I've tested such cases:

<option value="en" th:data-imagesrc="@{/images/en.png}">
  English
</option>

and

<option value="en" data-imagesrc="@{/images/en.png}">
  English
</option>

But both cases are failed. What is the correct way to set HTML 5 attribute like it's th:src or th:href?

Tom Bunting
  • 1,845
  • 16
  • 24
Oleg Barmin
  • 41
  • 1
  • 4

1 Answers1

0

Use th:attr

In your case

<option value="en" th:attr="data-imagesrc='__@{/images/en.png}__'">
  English
</option>

or there are 3rd party libs like created for html5 data attrs

https://github.com/mxab/thymeleaf-extras-data-attribute

Faraj Farook
  • 14,385
  • 16
  • 71
  • 97