Question: HTML5 allows some tags to be written more liberally i.e without corresponding END tags. e.g. `input` need not be closed `</input>`.However if choose **template mode** `HTML5` in Thymeleaf the Thymeleaf engine complains about this and does not parse the HTML template. I want to override this default Strict tag checking behavior. i.e Thymeleaf should parse an HTML template with meta and input (AND ALIKE) tags WITHOUT THEIR RESP. CLOSING TAGS. Pl. guide.

It also complains when you have something like this 

```
<a href="/home/pic/image.png" download="/path/to/file" data-gallery></a>

```

It throws an exception when it encounters the **data-gallery** throws "should be followed by '=' " which is kind of annoying as it takes the flexibility out of HTML5.

Answer: 
Here is how you can do it in a neat way

**Step 1:** Add thymeleaf mode to your application.properties file.

> 
> resources/application.properties
> 
> 
> 

```
spring.thymeleaf.mode=LEGACYHTML5

```

**Step 2:** Add nekohtml dependency to your pom.xml file.

> 
> pom.xml
> 
> 
> 

```
<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
</dependency>

```
Using `LEGACYHTML5` worked for me as well. 

Also it is necessary to add 

```
<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
</dependency>

```

to pom.xml as stated above. But there is one more step which might occur. After doing those two steps I was getting: 

```
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

```

To avoid this it is necessary to add

```
<dependency> 
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version>
</dependency>

```

to pom.xml