html★ is built on progressive enhancement. This guide describes the full three-layer architecture for building resilient web applications.

The Three Layers

Each layer enhances the one below it. Remove any layer and the page still works — it just loses that layer's enhancements.

Layer 1: HTML (Server-Rendered)

The foundation. A server renders complete HTML pages. Every link navigates, every form submits, every piece of content is readable — with zero JavaScript.

Without JavaScript, this page works. Links navigate to full pages. Forms submit with page reloads. Content is visible and indexable.

Layer 2: html★ (AJAX Enhancement)

Add html★ attributes and the same HTML gets AJAX behavior:

Now:

  • Category links fetch fragments and swap into #product-list without page reload
  • The add-to-cart form submits via AJAX, updating #cart-status
  • URLs update via data-push, back button works
  • View Transitions animate the content swap

If html★ fails to load, the page falls back to Layer 1 behavior.

Layer 3: Custom Elements (Rich Interactivity)

For components that need more than AJAX — client-side state, animations, complex interactions — use Custom Elements:

All three layers are independently valuable and gracefully degrade:

ScenarioWhat Works
No JavaScriptLayer 1: Full page navigation, form submission
html★ loaded, CE notLayers 1-2: AJAX nav, partial updates, transitions
Everything loadedAll layers: Full interactivity
html★ fails, CE loadsLayers 1+3: Full pages with rich components

Example: This Documentation Site

This site demonstrates all three layers:

  1. Layer 1 (HTML): Astro renders complete HTML pages on the server. With JavaScript disabled, every page is readable and every link navigates.

  2. Layer 2 (html★): Navigation uses data-target="#content" and data-select="#content" for AJAX page transitions with View Transitions animations.

  3. Layer 3 (Custom Elements): <code-block> provides syntax highlighting, <dropdown-wc> handles header navigation menus, <search-wc> powers the search dialog.

Best Practices

  1. Build Layer 1 first. Make sure the page works without any JavaScript. This is your baseline.

  2. Add html★ second. Put data-target on navigation containers, data-push for URL management. The page now has AJAX without any custom JavaScript.

  3. Add Custom Elements last. Only for components that genuinely need client-side logic — not for things html★ already handles.

  4. Keep layers independent. Custom Elements shouldn't depend on html★, and html★ doesn't depend on Custom Elements. Each layer should enhance the page on its own.

  5. Test each layer in isolation. Disable JavaScript to test Layer 1. Remove Custom Element scripts to test Layers 1+2. This ensures graceful degradation actually works.