liveBook · Manning

Chapter 3: The user interface

What you will learn in chapter 3 of Vanilla Web

The chapter introduces a platform-first approach to UI and explains why Vanilla Web favors declarative HTML, CSS, and native controls.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces a platform-first approach to UI and explains why Vanilla Web favors declarative HTML, CSS, and native controls.

Key terms: UI, UX, reachability, accessibility, usability, declarative, HTML, CSS, native controls, keyboard support

3.1 Defining our user interface

The section compares UI stacks, favors a declarative HTML-and-CSS approach, identifies the HTML document as the starting point for any web UI, and broadens UI design beyond the display.

Key terms: declaratively, HTML, CSS, JavaScript, web rendering engines, UI stack, HTML and CSS, Canvas, <canvas>, web assembly

3.2 The ultimate responsive design

This section argues for interfaces that adapt to unpredictable screen sizes and screenless consumers, and distinguishes search-engine optimization from optimization for AI tools.

Key terms: responsive design, form factor, screenless systems, Search Engine Optimization, SEO, Generative Engine Optimization, GEO, semantic HTML, metadata

3.3 Web metadata

Defines web metadata as information that shapes the browser and operating-system presentation of a site without changing its viewport content, and notes that some metadata can vary by page or change dynamically.

Key terms: metadata, web rendering engine, viewport, browser’s chrome UI, title, icons, theme color, multipage app, client-side application

3.3.1 Title

Explains what the document title communicates and when to update it as a page or app view changes.

Key terms: <title> element, route, server-side, single-page apps, document.title

3.3.2 Web app manifest

This section explains how a linked Web App Manifest supplies application metadata and how its basic properties shape an installed app’s identity, navigation, launch, and appearance.

Key terms: Web app manifest, JSON, link element, id, name, short_name, scope, start_url, display, standalone

3.3.3 Icons

This section explains where web app icons are used, which icon files to prepare, and where to declare them.

Key terms: favicon, pinned shortcuts, Web App Manifest, Apple Touch icon, mask icon, SVG, PNG, rel=icon, rel=mask-icon, purpose=maskable

3.3.4 Theme color

Explains how to suggest browser and installed-app chrome colors using HTML theme-color metadata and a manifest theme_color value, including platform limits.

Key terms: theme-color meta tag, UI chrome, light and dark preferences, theme-color, theme_color, Web App Manifest

3.3.5 Viewport definition

This subsection explains how viewport settings affect mobile page width, display cutouts, and virtual-keyboard resizing.

Key terms: viewport, width=device-width, initial-scale=1, viewport-fit=cover, safe-area CSS env() variables, interactive-widget, manifest, resizes-visual, resizes-content, overlays-content

3.3.6 Semantic metadata

Explains how metadata in an HTML document’s head describes a page to search engines and other agents and helps shared links display rich previews.

Key terms: <meta>, description, keywords, author, generator, robots, noindex, nofollow, charset, UTF-8

3.3.7 Putting the metadata together

The section introduces a forthcoming HTML metadata example for a coffee-selling Vanilla Web application, but does not provide the example or explain any metadata.

3.4 Semantic HTML

Introduces semantic HTML as a way to describe an app’s content and structure before styling its appearance.

Key terms: data, semantics, semantic HTML, HTML structure, CSS, title, navigation bar, sections

3.4.1 Using the Right Element

This section explains why choosing the right semantic HTML element matters even when it barely changes how a page looks.

Key terms: semantic tag, usability, accessibility, discoverability, SEO, GEO

3.4.2 Avoiding divitis and other problems

This section explains why overusing <div> obscures a page’s meaning and how semantic elements and meaningful class names make markup clearer.

Key terms: <div>, divitis, HTML semantics, semantic elements, <header>, <footer>, <main>, <nav>, lists, class names

3.4.3 Semantic attributes

This section explains how HTML attributes convey meaning and behavior to browsers, CSS, JavaScript, and assistive technologies.

Key terms: semantic attributes, inputmode, download, alt, hidden, disabled, inert, draggable, DOM, lang

3.5 Accessibility

This section explains why accessibility matters and introduces semantic HTML, resilient design, and careful use of ARIA as foundations for an accessible interface.

Key terms: accessibility, a11y, temporary disabilities, situational ones, resilience, semantic HTML, semantic tags, progressive enhancement, <div>, <span>

3.5.1 Landmarks

This section explains how semantic HTML landmarks help people navigate large documents with assistive technology.

Key terms: landmarks, assistive technologies, screen reader

3.5.2 Forms

This section explains how to make form inputs accessible through labels and error messages, and why custom controls require extra care.

Key terms: <label>, for/id, placeholder text, aria-describedby, custom UI kits, focus, labels, ARIA attributes

3.5.3 Keyboard Navigation

This section explains how to make an app usable with a keyboard alone by preserving a sensible navigation order, visible focus, and testing without a pointer.

Key terms: keyboard alone, DOM, natural order, tabindex, Tab, Enter, outlines, focus indicator, custom focus style

3.5.4 ARIA Roles

This section explains what ARIA roles label and when to use them instead of native semantic elements.

Key terms: Roles, role, native equivalent, semantic elements

3.5.5 ARIA states and properties

This section explains how ARIA states and properties convey a component’s current condition and provide extra context.

Key terms: ARIA states, ARIA properties, aria-expanded, aria-label, aria-describedby

3.5.6 Color and contrast

Explains how text contrast and non-color cues make a Vanilla Web interface more accessible, and how to check those choices.

Key terms: contrast ratios, WCAG 2.1 AA, standard text, large text, color, text, icons, WCAG, browser DevTools, WAVE extension

3.5.7 Interactive elements

This section recommends native HTML controls for accessible interactions and states the responsibilities that come with custom widgets.

Key terms: native HTML controls, semantics, keyboard interaction, focus management, custom widgets, ARIA attributes, pointer and keyboard events, minimum target size, semantic HTML, ARIA

3.5.8 Screen readers

This section explains how screen readers use DOM semantics and why accessibility should be tested with a real screen reader rather than by disabling CSS.

Key terms: DOM, headings, landmarks, semantic roles, screen readers, screen reader, assistive tech, CSS, VoiceOver, NVDA

3.6 Media resources

This section explains why media format choices matter for a fast, accessible, and compatible web UI.

Key terms: media, formats, bandwidth, compatibility

3.6.1 Image formats

This section compares common bitmap and vector image formats and explains how the browser selects among image sources supplied with <picture>.

Key terms: bitmap images, PNG, JPEG, WebP, AVIF, vector graphics, SVG, resolution-independent, CSS, <picture>

3.6.2 Video formats

This section compares web video format choices and gives basic guidance for embedding accessible, compatible video.

Key terms: MP4, H.264, WebM, VP9, AV1, controls, multiple sources, autoplay with sound, decorative

3.6.3 AR formats

This section compares portable 3D asset formats, explains a progressively enhanced approach to displaying models and AR, and advises how to prompt AI coding tools for better web markup.

Key terms: glTF, USDZ, AR Quick Look, progressive enhancement, <model>, <model-viewer>, <a rel="ar">, semantic HTML, accessibility, modern CSS layout techniques

3.7 Rich web UI controls

This section explains why native browser controls are a practical starting point for rich, accessible interfaces.

Key terms: native UI controls, widgets, CSS, accessibility

3.7.1 Summaries

This section explains how HTML provides a disclosure widget with native interaction and CSS styling options.

Key terms: <details>, <summary>, disclosure widget, :open, ::details-content, summary marker

3.7.2 Accordions

This section explains how named <details> elements create an exclusive accordion without JavaScript state coordination.

Key terms: accordion, <details>, name attribute, exclusive accordions

3.7.3 Modal dialogs

This section introduces modal dialogs and explains how the native <dialog> element supports focus control and simpler ways to open and close them.

Key terms: modal dialog, <dialog>, native focus trapping, closedby="any", command="show-modal", light-dismiss, declarative triggering

3.7.4 Carousels

This section explains what carousels are and how CSS and browser features can provide interactive, accessible carousels without JavaScript libraries.

Key terms: carousels, scrolling lists, overflow-x: auto, scroll-snap-type, ::scroll-button(left), ::scroll-button(right)

3.7.5 Popovers

This section introduces native popovers, how to connect a trigger to a panel, and how to style or extend them.

Key terms: popover, popovertarget, :popover-open, Popover API

3.7.6 Rich selectors

This section shows how to customize a native select element’s appearance while retaining its built-in behavior and a working fallback.

Key terms: <select>, appearance: base-select, ::picker(select), ::picker-icon, :checked, <selectedcontent>, non-compatible browser, classic select, falls back

3.7.7 Other UI controls

Introduces emerging native UI controls that may replace some custom-built widgets, while noting that browser support is still evolving.

Key terms: hovercards, <progress>, progress ring, toolbars, menus

3.8 Beyond basic UI

This section introduces Web platform capabilities beyond HTML and CSS for creating or enhancing a user interface.

Key terms: HTML and CSS stack, JavaScript, Web API, user interface

3.8.1 Using canvas

Introduces canvas as a JavaScript-rendered area of an HTML document and cautions against using it for content better rendered with HTML and CSS.

Key terms: Canvas, context, 2D context, WebGL, HTML and CSS stack, accessibility, usability, discoverability

3.8.2 Using UI-related APIs

This section surveys browser APIs that extend interfaces beyond HTML and CSS and explains how to use them without making the core experience depend on their availability.

Key terms: Fullscreen API, Picture-in-Picture API, Casting APIs, Media Session API, Window Segments, WebXR APIs, Web Speech API, semantic markup, Baseline, feature detection

3.9 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 2: Understanding the web platform Chapter 4: Vanilla CSS →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.