GitHub v1.3.1
Lesson 02

Semantic Tags

Coralite does not invent new HTML wrappers. It uses the platform's native semantic elements to structure your application.

Structure over Styling

Before we build interactive Web Components, we must structure the document correctly. Semantic HTML elements like <header>, <main>, and <article> give meaning to your content, benefiting both accessibility tools and search engines.

html
Code copied!
  <main>
    <article>
      <header>
        <h1>My First Post</h1>
      </header>
      <section>
        <p>This is the content.</p>
      </section>
    </article>
  </main>

Semantic Templates in Coralite

When you author a Coralite component, your <template> is not restricted to just <div> tags. You should use semantic tags exactly as you would in a standard HTML document. The custom element acts as the boundary, while the inner HTML provides the structure.

html
Code copied!
  <template id="blog-post">
    <article>
      <header>
        <h2>{{ title }}</h2>
      </header>
      <section>
        <slot></slot>
      </section>
    </article>
  </template>
  
  <script type="module">
    export const attributes = {
      title: { type: String, required: true }
    }
  </script>

Why this matters

Because Coralite renders Light DOM, these semantic tags remain in the final DOM tree. There is no Shadow DOM boundary preventing assistive technologies from understanding the hierarchy of your page.