Skip to content

<a> tags cannot be self-closing #200

@Rich-Harris

Description

@Rich-Harris

Just encountered an interesting bug. The Svelte SSR compiler uses self-closing tags for elements without children:

<div/> <!-- equivalent to <div></div> -->

But that doesn't work with some elements:

<a href='https://whatever.com'/>
<p>this will be included in the link!</p>

It needs to be <a ...></a> instead. Empty anchor tags is a bit of an edge case, but it should still be handled. Am wondering which other elements can't use self-closing tags though. A quick Google doesn't yield anything interesting – does anyone out there know the answer? Or should we just always use closing tags for non-void elements?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions