GitHub v1.3.1
Lesson 04

Structuring a Page

Pages are not special. They are standard HTML documents that compose the custom elements you have built.

The Assembly Root

In Coralite, a page is just an .html file inside src/pages/. Its job is to assemble your components into a meaningful document structure using standard semantic tags like <main> and <section>.

html
Code copied!
  <html lang="en">
  <head>
    <title>My App</title>
  </head>
  <body>
    <site-header></site-header>
    
    <main>
      <hero-section></hero-section>
    </main>
    
    <site-footer></site-footer>
  </body>
  </html>

Defining the Components

The <hero-section> and <site-header> tags are custom elements defined in your src/components/ folder. They handle their own internal markup and logic.

html
Code copied!
  <template id="hero-section">
    <section class="hero">
      <h1>{{ headline }}</h1>
      <p>{{ subhead }}</p>
      <ui-button>Get Started</ui-button>
    </section>
  </template>
  
  <script type="module">
    export const attributes = {
      headline: { type: String, default: 'Welcome' },
      subhead: { type: String, default: 'Build something great.' }
    }
  </script>

No Wrappers Required

Notice that the page does not wrap the components in extra <div> tags. Because Coralite renders Light DOM, the <hero-section> custom element acts as the boundary. You can style it directly using CSS.

This keeps your DOM tree clean, shallow, and highly performant.