DEV Community

Cover image for Building the Modern Web with AI: Getting Started with Modern Web Guidance
Luca Del Puppo for Playful Programming

Posted on Originally published at blog.delpuppo.net on

Building the Modern Web with AI: Getting Started with Modern Web Guidance

Ask a coding agent to build a settings page, and there are several ways it might implement the same interaction. An “Edit profile” button could open a custom overlay with its own keyboard handlers, or a native dialog whose modal behavior is handled by the browser. Both might look convincing in a screenshot.

The differences become more interesting when you press Tab, try to cancel an invalid form, or change your device’s color scheme.

In this two-part series, we’ll use Modern Web Guidance to build and inspect a small preferences page. We’ll follow the implementation choices, then test the resulting behavior. You’ll need basic HTML, CSS, and JavaScript knowledge; you don’t need a framework or previous experience with agent skills.

Give the agent a place to check its approach

An agent skill is a package of instructions and supporting resources that a compatible coding agent can load for a task. It helps shape how the agent works. It doesn’t become a dependency of the website you ship.

Modern Web Guidance brings web-platform guidance into that workflow. When a task needs it, the skill directs the agent to search for relevant guides and retrieve their implementation patterns, caveats, and compatibility advice. The project started with Chrome and now also involves other browser teams. Modern Web Guidance documentation · Version 1.0 announcement

For our page, the useful questions are specific: how should a modal manage focus? How should a theme override interact with the operating system? What should happen when a form is invalid?

The skill gives the agent material to consult for those questions. We still decide what the product should do and check whether the implementation does it.

Start with the demo

The example is Common Ground , a fictional application with one preferences page. You can edit a display name and bio, choose a theme, and save two notification preferences. Nothing is uploaded, and those notification settings don’t send emails.

With Git, Node.js 26 or newer, and npm installed, run:

git clone https://github.com/Puppo/modern-web-guidance-demos.git
cd modern-web-guidance-demos
git switch article-1/guided
npm ci
npm start

Enter fullscreen mode Exit fullscreen mode

Open the local demo. The page has no build step or browser runtime dependencies. The local server uses the pinned http-server development dependency. The source checkpoint for this article is preserved separately from the later refinements.

Common Ground preferences page with profile editing, three theme options, and independent notification preferences

Start with Edit profile. Change the name, press Escape, and reopen the dialog. Your saved name should be restored. Later, we’ll connect that behavior to the native dialog and the application’s draft handling.

Install Modern Web Guidance for your own implementation

If you want to build your own version, start from the empty starter in a separate checkout:

git clone https://github.com/Puppo/modern-web-guidance-demos.git modern-web-guidance-exercise
cd modern-web-guidance-exercise
git switch experiment/starter
git switch -c my-preferences-demo

Enter fullscreen mode Exit fullscreen mode

Open the checkout in Google Antigravity and enable Modern Web Guidance during setup. If Antigravity is already installed, open Settings → Customizations → Build with Google Plugins and enable it there. The Chrome for Developers installation guide walks through both options. The completed demo runs without the skill installed.

You can also inspect guidance directly. These are example commands using a query and guide ID consulted during the demo work:

npx modern-web-guidance@latest search "build accessible modal dialog"
npx modern-web-guidance@latest retrieve "dialog"

Enter fullscreen mode Exit fullscreen mode

Search returns candidate guides. For the profile editor, dialog is the match. The guide recommends opening a modal with the native <dialog> element and showModal() so the browser manages modal focus and makes the rest of the page inert. That gives the agent a specific implementation to try and gives you behavior to check.

Try this prompt in Antigravity. It is adapted from the demo requirements:

Use Modern Web Guidance to build a standalone user preferences page with vanilla HTML, CSS, and JavaScript. Include a profile-editing dialog, system/light/dark themes, and two independent notification preferences. Keep profile edits separate from preference changes. Canceling or dismissing the dialog must discard its draft. Persist saved choices locally and explain when storage fails. Consult the relevant guides before implementing each part. Target Baseline Widely available features, with usable fallbacks for newer enhancements. For the profile editor, report the guide you retrieved, the recommendation you applied, and what you verified with the keyboard.

Keep the browser-support requirement explicit. A compatibility target helps the agent choose an approach, but it doesn’t prove that your page has been tested in those browsers.

Let the browser handle the modal

The demo uses <dialog> for profile editing. This excerpt keeps the naming relationship and opening call visible; the complete form and handlers are in the HTML and JavaScript.

<dialog
  id="profile-dialog"
  aria-labelledby="dialog-title"
  aria-describedby="dialog-help"
  closedby="any"
>
  <form id="profile-form" method="dialog" aria-labelledby="dialog-title">
    <h2 id="dialog-title">Edit your profile</h2>
    <p id="dialog-help">
      Make it yours. Canceling or dismissing discards your edits.
    </p>
    <!-- Profile fields and actions -->
  </form>
</dialog>


const dialog = document.querySelector('#profile-dialog');
// After restoring the saved values into the form:
dialog.showModal();

Enter fullscreen mode Exit fullscreen mode

Opening it modally gives the browser responsibility for making the background inert and managing the modal focus behavior. The implementation doesn’t add a second focus trap, redundant dialog roles, or its own Escape handler.

closedby="any" adds outside-click dismissal where supported. The demo retains Cancel and Escape when that enhancement is unavailable. This is a deliberate compatibility choice: outside-click dismissal is useful, but editing and cancellation must not depend on it.

The browser doesn’t know our application’s save rules, though. Opening the dialog copies the saved profile into the fields. Saving applies the edited values. Canceling leaves the saved profile untouched, and reopening restores that saved version.

Try the result with the keyboard. Tab to Edit profile and press Enter. Focus should move to the display-name field. Press Tab and Shift+Tab to move through the dialog and check that the background controls stay out of reach. Change the name, press Escape, and confirm that focus returns to Edit profile. Reopen the dialog to check that the unsaved name was discarded. The focus behavior comes from the native modal. Discarding the draft is an application rule.

Keep the form controls recognizable

The page uses radio buttons for the three mutually exclusive theme options and checkboxes for independent notification preferences. Styling changes their presentation while keeping the native controls in place.

The profile form uses browser constraints too. Here is the display-name field, with its surrounding label and descriptions shortened:

<label for="display-name">Display name (required)</label>
<p id="name-help">Up to 60 characters.</p>
<input
  id="display-name"
  name="displayName"
  autocomplete="nickname"
  required
  maxlength="60"
  pattern=".*\S.*"
  aria-describedby="name-help name-error"
  autofocus
>
<p id="name-error" aria-live="polite"></p>

Enter fullscreen mode Exit fullscreen mode

required rejects an empty value. The pattern also requires a non-space character, so a name consisting only of spaces is rejected. The invalid handler supplies a visible explanation and focuses the field. While the user types, the input handler clears the existing error once the value becomes valid.

Cancel has formnovalidate. A user should be able to abandon an invalid draft without first fixing it. Try submitting a blank name, then canceling: the dialog should close and the previous profile should remain.

Make theme selection include the browser’s controls

A dark page with bright native inputs is an easy detail to miss. The theme implementation therefore updates the page’s color scheme as well as its own color tokens.

The theme guides led us to declare support for both color schemes and apply the selected scheme to the root element. This lets native controls follow the same choice as the page colors. The stylesheet includes the override selectors, light-dark() tokens, and fallback colors.

System mode stores no explicit theme override. If you save Dark, that choice remains Dark even when the OS changes. If you save System, the page follows the OS again. A small guarded script restores a saved override before the page finishes loading; blocked storage leaves the system default available.

The palette, spacing, and visual identity are choices made for this demo. They aren’t evidence that the skill automatically supplies a good design for every product.

Keep the result honest

This implementation was developed with the skill available and with the project requirements already discussed. It is a practical walkthrough, not a controlled comparison with an otherwise identical agent run without the skill.

The source includes verification notes. Initial browser checks covered editing, cancellation, persistence, validation, theme changes, and storage failures. Those checks also led to corrections recorded alongside the code.

For your own exercise, review the choices the agent made. Can you explain the dialog’s dismissal behavior? Can you find where a preview becomes a saved preference? Does an error message describe what actually happened?

In part two, we’ll use Modern Web Guidance to scan an existing form for legacy patterns, evaluate the findings, and modernize textarea sizing and validation feedback.

See you soon!

Top comments (0)