stnd.build

Semantic Tag Redundant

Error: [ERR_SEMANTIC_TAG_REDUNDANT] Found tag-duplicating class ".X" on <tag>. Standard Architecture: Rely on native semantic HTML and component-scoped CSS.


The Problem

A semantic HTML5 element (<main>, <header>, <footer>, <nav>, <aside>, <dialog>) carries a class that redundantly repeats the element’s own tag name.

<!-- Problematic -->
<main class="studio-main prose rhythm">
<header class="app-header">
<nav class="sidebar-nav" aria-label="Chapters">
<footer class="dialog-footer">

The Why

In modern web development with Astro and Svelte, component styles declared inside <style> tags are automatically scoped to that specific component at compile time.

  1. Tag name duplication is BEM legacy baggage: In older frameworks without scoped CSS (or vanilla WordPress templates), developers named every element defensively (.studio__header, .mycomponent__main) to prevent CSS leakage. In Astro and Svelte, <style> is already scoped: writing header { ... } or nav { ... } does not leak outside the component.
  2. Semantic HTML speaks for itself: HTML5 specifies unique roles for landmarks (<main>, <nav>, <header>, <footer>). Adding .studio-main to <main> or .sidebar-nav to <nav> adds pure noise, bloats the DOM, and undermines the clean elegance of semantic HTML.

The Solution

Rely on the semantic element directly and let the compiler scope the styles.

1. Let the tag speak for itself

Remove the redundant class completely. Use framework intention classes (prose, rhythm, canvas) if layout formatting is needed, or no class at all:

<!-- Clean -->
<main class="prose rhythm">
<header>
<nav aria-label="Chapters">
<footer>

2. Style via semantic selectors in scoped <style>

In your component’s <style> block, target the semantic element directly instead of inventing a redundant class:

/* Inside component <style> */
main {
  width: 100%;
  min-width: 0;
}

header {
  border-bottom: var(--border);
  padding-block: var(--space-d2);
}

nav {
  display: flex;
  gap: var(--space);
}

3. Use native attributes for state and variants

If you need to indicate state or variation, use native attributes and ARIA roles rather than custom classes: