Skip to content

Svelte Adding class="<svelte-component-identifier>" to meta/link/script tags in the <svelte:head></svelte:head> #17223

@redesigned

Description

@redesigned

Describe the bug

Svelte Adding class="" to meta/link/script tags in the svelte:head if there is a style block on the component. These elements should not have a class attribute and are not styleable.

Is there a reason for this, I'm not understanding? Or is this a bug that needs fixing?

example: <meta name="author" content="Re:Designed" class="s-Oo-daCANuhh7">

Image

Reproduction

<svelte:head>
	<meta name="author" content={author} />
	<link rel="author" href={author_url} />
	<script type="application/ld+json"></script>
</svelte:head>

<div class="credits">
Site by <a href={author_url} target="_blank" rel="noopener noreferrer author" title={`Authored by ${author}`}><nobr>{author}</nobr></a>
</div>

<script lang="ts">
	interface Props {
		author?: string,
		author_url?: string,
	}
	let {
		author = 'Anonymous',
		author_url = 'https://example.com',
	}: Props = $props()
</script>

<style>
</style>

Remove the empty style block and the classes go away.

I have components that both add things to the head and have styleable blocks, but nothing in the head is styleable and i don't think it should ever have a class applied to it, correct?

Besides bloating the HTML and not having any valid meaning/effect it doesn't seem to be hurting anything, but I figured I should report it and see if it could be resolved if it isn't intended.

Many Thanks!

System Info

System:
    OS: macOS 26.0.1
    CPU: (8) arm64 Apple M2
    Memory: 71.91 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.2.1 - /Users/joshuajarman/.asdf/installs/nodejs/25.2.1/bin/node
    npm: 11.6.2 - /Users/joshuajarman/.asdf/plugins/nodejs/shims/npm
    pnpm: 10.23.0 - /Users/joshuajarman/.asdf/installs/pnpm/10.23.0/bin/pnpm
    Deno: 2.5.6 - /opt/homebrew/bin/deno
  Browsers:
    Chrome: 142.0.7444.176
    Edge: 142.0.3595.94
    Firefox Developer Edition: 145.0
    Safari: 26.0.1
  npmPackages:
    svelte: ^5.43.14 => 5.43.14

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions