Docs / Making content / HTML textures: modern engine
What the HTML engine supports
On this page
A page can be a small site: .html, .css, .js files (and ES modules) in its folder, linked
as on the web. The engine is not a browser, so a page that looks fine in Chrome may still need
a few changes; when something doesn't show up, check this list first. Text is drawn in Inter.
HTML#
- Nested elements,
<style>,<script>,<link rel="stylesheet" href>,<script src>, inlinestyle="", all attributes (data-*too), entities such as&. - Block elements (
div,p,h1-h3,section,ul...) with browser-like default sizes and margins; inline elementsspan,b,strong,i,em,a,small,u,s,label,code..., and<br>. <button>comes with a default look.<tr>is a row and<td>/<th>equal cells of it.<img src width height>(bmp, dds, tga, jpg, png), looked up next to the page.<head>,<title>,<meta>,<template>are read and not drawn. A<script>whosetypeis not JavaScript ormodule(a JSON block, a template) is not run.
Not available: canvas, lists markers (bullets), form controls beyond a look of your own, iframes, video, svg.
CSS#
Selectors: tag,
#id,.class,*, compounds (div.a#b), attribute selectors ([a],[a=b],^=,$=,*=,~=,|=), the combinators space,>,+,~, the pseudo-classes:first-child,:last-child,:only-child,:nth-child(),:nth-last-child(),:nth-of-type(),:first-of-type,:last-of-type,:not(),:empty,:root, comma lists.:hover,:focusand::before/::afternever match (a texture has no pointer state and no generated content). Specificity and!importantwork.- Values:
calc(),min(),max(),clamp(), custom properties--namewithvar()(inherited, with fallbacks),currentcolor, colours as names,#rgb,#rrggbb,rgb(),rgba(),hsl(),hsla(). Unitspx,%,em,rem,ex,ch,pt,pc,cm,mm,in,vw,vh,vmin,vmax. - Box:
width,height,min-/max-widthand-height,margin(withauto),padding,box-sizing,border(and the per-side forms; solid lines, other styles draw as solid),border-radius(one radius;50%makes a circle),overflow(hidden clips),opacity,box-shadow(the first, not inset),visibility,display. - Position:
position: relative | absolute | fixedwithtop,right,bottom,left,insetandz-index. An absolute box sits in its nearest positioned ancestor; fixed is relative to the texture. - Flexbox:
display: flex | inline-flex,flex-direction,flex-wrap,flex-flow,justify-content,align-items,align-self,gap/row-gap/column-gap,flex,flex-grow,flex-shrink,flex-basis,order, auto margins. - Background:
background-color,background-image: url(),linear-gradient()(angles andtodirections, any number of stops),background-size,-repeat,-position. - Text:
color,font-size,font-weight,text-align,line-height,letter-spacing,text-transform,text-decoration(underline, line-through),white-space: nowrap,text-overflow: ellipsis(withoverflow: hidden),vertical-align: middlefor inline blocks.
Not available: grid (it lays out as a column), floats, animations and transitions, custom
fonts, @media, @font-face, @keyframes, per-corner radii, outlines.
JavaScript#
The scripts run in Boa, a complete JavaScript engine: modern syntax (classes with private
fields, arrow functions, template strings, destructuring, spread, optional chaining, ??,
generators, async/await, ES modules), and the standard library (Promise, Map, Set,
WeakMap, JSON, RegExp, Date, Math, typed arrays, Symbol, Proxy, Reflect, ...).
Promises run after the script that made them. Not included: Intl.
- Modules:
<script type="module">(inline orsrc) andimport ... from './file.js', relative to the importing file, from the page's folders only. DOM:
document.getElementById,querySelector(All),getElementsBy...,createElement,createTextNode,body,documentElement;on elements
appendChild,append,prepend,insertBefore,before,after,replaceWith,remove,cloneNode,children,childNodes,parentNode,firstChild...,nextElementSibling...,textContent,innerText,innerHTML,outerHTML,insertAdjacentHTML,id,className,classList,dataset,style(any property,setProperty,cssText),getAttribute...,matches,closest,getBoundingClientRect,offsetWidth...,hidden,value,src.getComputedStyle(el)knows the size, display, colour, opacity and box properties of a laid out element.- Events:
addEventListener(withonce),removeEventListener,on...properties andon...=""attributes,dispatchEvent,Event,CustomEvent. A press on the texture ispointerdown,mousedown, then on releasepointerup,mouseupandclick, bubbling up todocumentandwindow; moves aremousemove.DOMContentLoadedandloadfire once the scripts have run. - Timers:
setTimeout,setInterval,clear...,requestAnimationFrame. They run while the page is being drawn and use real time. At most 64 are active at once. - Files:
fetch('data.json')reads a file below the page's folders (text,json()); nothing else is reachable and there is no network. - Browser objects that exist so libraries do not stop:
window,navigator,location,history,screen,localStorage/sessionStorage(kept while the page lives),performance.now(),matchMedia,MutationObserverand friends (do nothing),atob/btoa,structuredClone,console.
Three limits protect the game from runaway pages: one loop may run about five million times,
function calls nest 400 deep, and a script that goes past either is stopped (an error in the
log; the page and its other scripts go on, and a catch cannot swallow the stop).
Redrawing#
A page is redrawn when the DOM or the styles change. The simplest pattern, and the one that
works best in this engine, is to rebuild a block with innerHTML in your update function
and only do that when the data actually changed (compare against the last values you saw).
Redrawing on every call wastes time on a slow phone.
Something wrong or missing? Fix it on GitHub or open an issue.