Efaz
Efaz

Reputation: 304

How to add a break or new line in Thymeleaf?

This is my code using the Thymeleaf template

<form>
     <label>
          <input type="checkbox" th:each="activeMeal : ${activeMeals}" th:text="${activeMeal.itemName}">
     </label>
</form>

This is getting generated:

enter image description here

I want each checkbox in a separate line. In a normal plain HTML I would use the <br/> tag to create the breaks. But it does not seem to be working in inside the Thymeleaf tags.

Upvotes: 2

Views: 2073

Answers (1)

Efaz
Efaz

Reputation: 304

<th:block th:each="activeMeal : ${activeMeals}">
    <input type="checkbox" name="selectedActive" id="selectedActive" th:value="${activeMeal.itemName}"/>
    <label th:text="${activeMeal.itemName}"></label>
    <br/>
</th:block>

Upvotes: 1

Related Questions