Home > Mobile >  Self-closing tag syntax error in HTML documents
Self-closing tag syntax error in HTML documents

Time:09-28

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?

CodePudding user response:

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.

CodePudding user response:

I started getting this message today as well on my link rel="canonical" line. How is this resolved, please?

  • Related