HTML structure

Every page moss builds shares this DOM layout, mirroring the shell.html, article-content.html, and page-content.html templates inside moss.

<html data-theme="light">
  <body>
    <nav class="main-nav">
      <div class="nav-content">...</div>
    </nav>
    <main class="container">
      <article>
        <h1 class="article-title">...</h1>
        <div class="article-meta">
          <time class="article-date">...</time>
        </div>
        <!-- page content -->
      </article>
    </main>
    <footer class="moss-colophon">...</footer>
  </body>
</html>

Key selectors

SelectorWhat it is
.main-navTop navigation bar
.containerMain content wrapper
articlePage content area
.article-titlePage heading
.article-metaDate and metadata
.moss-colophonFooter

Content inside article and .moss-colophon is safe to modify from script.js. The navigation structure is managed by moss — add styles, but do not remove or reorder its children.

Data attributes

These attributes are set by moss on HTML elements. Read them in script.js or target them in style.css.

AttributeElementValuesPurpose
data-theme<html>"light", "dark"Current color theme
data-moss-preview<body>present/absentSet when in preview mode
data-comments<article>"true", "false"Whether comments are enabled
data-source-lineheadings, paragraphsline numberSource markdown line (dev aid)
data-content-width<article>"wide"Content width override

Read data-theme in JavaScript:

const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
Published with moss