# WEB Document Format (`.webd`) | | | | --- | --- | | **Version** | `0.1.0` | | **Extension** | `.webd` | | **Container** | ZIP archive | | **MIME type (proposed)** | `application/webd+zip` | | **Audience** | Tools, generators, and LLMs that **create** valid `.webd` packages | A `.webd` file is a self-contained, fixed-layout document package: HTML + CSS + embedded assets, with no JavaScript and no external resource dependencies. This document defines what to put in the package so that it is valid. --- ## 1. Create a package (recipe) 1. Build a directory with the layout in [§2](#2-package-layout). 2. Choose a document pattern ([§3](#3-document-patterns)): - **Single-page:** all content in `index.html`; omit `/pages/`. - **Multi-page:** one HTML file per page under `/pages/` (zero-padded names recommended); `index.html` is only a shell or local redirect. 3. Add root `styles.css` and package-local assets as needed ([§2.1](#21-embedded-assets-recommended-layout)). Prefer a single optional `assets/` folder. 4. Write `metadata.json` with every required field ([§6](#6-metadatajson)). Set `"format": "webd"` and `"version": "0.1.0"`. 5. Optionally add `manifest.json` (TOC), `/annotations/annotations.json`, or filled form values in the HTML. 6. Ensure all HTML, CSS, and JSON follow the content rules in this document. 7. ZIP the directory **contents** (not the parent folder). Entry names must be safe relative paths ([§2](#2-package-layout)). Name the file `*.webd`. 8. Optionally encrypt the ZIP with AES-256 ([§10](#10-optional-passcode-encryption)). --- ## 2. Package layout ### ZIP rules - The file is a standard ZIP archive renamed/extended as `.webd`. - Entry paths are relative to the package root, using `/` separators. - **Not allowed** in entry names: empty names, `..` segments, absolute paths (`/…`, `C:…`). ### Tree ```text document.webd (ZIP) | +-- index.html required +-- styles.css required +-- metadata.json required +-- manifest.json optional (TOC / labels) +-- pages/ optional (one .html per published page) | 0001.html | 0002.html +-- assets/ optional (recommended for all embedded media) | images/ | fonts/ | video/ | audio/ | … +-- annotations/ optional annotations.json ``` | Path | Required | Role | | --- | --- | --- | | `index.html` | Yes | Full document, or thin shell / local redirect for multi-page | | `styles.css` | Yes | Shared package stylesheet | | `metadata.json` | Yes | Document metadata | | `manifest.json` | No | Table of contents / navigation labels only | | `pages/*.html` | No | Fixed published pages (long documents) | | `assets/` | No | **Recommended** home for images, fonts, video, audio, and other embedded files ([§2.1](#21-embedded-assets-recommended-layout)) | | `annotations/annotations.json` | No | Highlights, comments, drawings, bookmarks | ### 2.1 Embedded assets (recommended layout) All package-local resources (images, fonts, video, audio, icons, downloadable attachments, and similar binary or static files) **should** live under a single optional root folder named `assets/`. | Rule | Detail | | --- | --- | | **Not required** | There is **no** mandatory folder name for assets. Packages without `assets/`, or with other package-relative locations, remain valid. | | **Recommended** | Put every embedded resource under `assets/` so tools, validators, and humans can find media in one place. | | **Subfolders** | Optional organization inside `assets/` is encouraged when helpful, e.g. `assets/images/`, `assets/fonts/`, `assets/video/`, `assets/audio/`, `assets/attachments/`. Flat layouts (`assets/logo.png`) are also fine. | | **References** | HTML `src` / `href` and CSS `url()` must stay **package-relative** (e.g. from `pages/0001.html`: `../assets/images/photo.png`). | | **Legacy / alternate layouts** | Root-level folders such as `images/`, `fonts/`, or `attachments/` are still allowed for compatibility with existing packages. Prefer `assets/` for new packages. | **Examples (all valid):** ```text # Recommended assets/logo.png assets/fonts/roboto.woff2 assets/video/overview.mp4 assets/audio/narration.m4a # Also valid (not preferred for new packages) images/logo.png fonts/roboto.woff2 media/clip.webm ``` ### Reserved paths (do not use in 0.1.0) `/signatures`, `/encrypted`, `/scripts`, `/versions` ### Page order - If `pages/` exists, **alphabetical filename order** is the only page sequence. - Prefer zero-padded names: `0001.html`, `0002.html`, … - Do **not** store `page_count`, `page_order`, or equivalent in JSON. --- ## 3. Document patterns ### Single-page Put the full document in `index.html`. Omit `pages/`. ### Multi-page - One fixed published page per file under `pages/`. - `index.html` must **not** duplicate page content. Use a shell or a **local** redirect only: ```html Redirecting… ``` - `meta http-equiv="refresh"` targets must be package-relative (never `http:` / `https:`). - From files under `pages/`, link the shared stylesheet as `../styles.css`. - Encode fixed page size in CSS and/or `metadata.json` (`page_width_px` / `page_height_px` / `page_size`). ### Links inside the package ```html Go to Section 2 ``` Target = package path `pages/0012.html` plus optional fragment. Cross-page links must use package-relative paths (or allowed navigational schemes in [§4](#4-html)). --- ## 4. HTML Applies to `index.html`, every `pages/*.html`, and any other `.html` entry. ### Allowed - HTML5 structure and content - Forms: `input`, `textarea`, `select` / `option` / `optgroup`, labels, fieldsets - Tables, lists, headings, semantic markup - Images, video, and audio with **package-relative** `src` (prefer paths under `assets/` — [§2.1](#21-embedded-assets-recommended-layout)) - Package-local stylesheets (``) - Inline styles (CSS inside them still follows [§5](#5-css)) - In-page anchors (`id`) - Package-relative cross-page links - Navigational `` schemes: package-relative paths, `webd:`, `https:`, `http:`, `mailto:`, `tel:`, `sms:` ### Not allowed - JavaScript: `