Re: Warning about self-closing syntax in embedded SVG within HTML file

Hi Graham,

Graham Bell <graham@editeur.org>, 2022-09-27 08:19 +0000:
> Archived-At: <https://www.w3.org/mid/8C5492A0-AAF5-40D8-8A48-A6ACD61982FA@editeur.org>
> 
> The validators (old and nu) now provide a warning against the use of the self-closing syntax. This is fine for void elements like <br> or <meta>.
> 
> But should it also warn against self-closing syntax within SVG that is directly embedded within the HTML (not a separate SVG file linked using <img>)?
> 
> This snippet generates warnings. Is this expected behaviour? It is not the same as recommending the removal of a / from an HTML void element.
> ...
> <path d="M 5 35 l 60 -25 10 5 5 10" />
> <path d="M 75 55 l 60 -25 10 5 5 10" />

Thanks for taking time to report this. I just added that warning today, and
I hadn’t considered the case of SVG.

It’s possible I can add an exception so that no warnings are reported for
SVG elements in HTML documents.

I’ll post a follow-up message here after I’ve looked into to it.

> Or is the recommendation to use this?
> 
> <path d="M 5 35 l 60 -25 10 5 5 10"></path>

For SVG in HTML, just <path d="M 5 35 l 60 -25 10 5 5 10"> — that is, just
the start tag, with no closing slash, and no end tag — should work.

But... I realize people don’t normally mark up their SVG that way, and
SVG tools don’t output SVG that way, because SVG is an XML thing, not
really an HTML thing.


So I think it’s best that you just able to keep your SVG content the way
you already have it, and I’ll update the checker to not report a warning
about SVG elements in HTML that use self-closing-tag syntax.

  –Mike

-- 
Michael[tm] Smith https://people.w3.org/mike

Received on Tuesday, 27 September 2022 08:38:29 UTC