Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Self-closing tag syntax error in HTML documents

Using the W3c.org HTML validator, today I started receiving a new error indicating an issue with all self-closing HTML tags. The error is:

Warning: Self-closing tag syntax in text/html documents is widely discouraged; it’s unnecessary and interacts badly with other HTML features (e.g., unquoted attribute values). If you’re using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool.

One of the examples of problematic HTML was:

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

Is this a recent change? What is the best practice for closing tags in light of this change?

like image 310
Susan Farrar Avatar asked May 22 '26 07:05

Susan Farrar


1 Answers

The error is

…a warning, not an error.

Is this a recent change?

It's not a warning I've come across before, and is under active development with an open issue relating to it so it is probably pretty new.

What is the best practice for closing tags in light of this change?

A matter of opinion. The warning gives the validator authors' opinion along with their justification.

like image 134
Quentin Avatar answered May 24 '26 23:05

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!