Late one evening you sit down to try the prototype your AI coding tool built, and you fill in the form the way a real user would. You tap Save, and the button changes to Saved before your finger leaves the trackpad, but when you reload the page, the entry is gone. So you open DevTools, the browser's inspection panel, and find a row in red: the request that was supposed to record the save had failed, and the screen said Saved anyway. The part of the app you were tapping runs on your own device, and its code changed the label before the request was even sent. You approved every line of this page yourself, and you cannot point to the one that did that.
The part of a website or app that runs on the user's device is the frontend, everything users see and touch: the buttons, the text, the layout, and the animation that shows a tap registered.
In the journey of a request, this part sent the request and showed the response. Builders call it the client: the half of the app on the user's phone or laptop, while the server is the other half. Its code turns your taps into requests and turns the responses into what the screen shows. In this chapter you read a few lines of frontend code, learn the screen elements AI apps added, and learn how to describe a screen so a tool can build it.
HTML, CSS, and JavaScript, the materials of every screen
Every page a browser shows mixes the same three materials, and the quickest way to learn them is to read a simplified version of that Save button's code. First, its HTML, the code that says what is on the page:
<button class="save-btn">Save</button>
The tag button says what this is, so the browser draws something tappable; the word Save between the tags is the label the user reads; and class="save-btn" is a name the CSS and JavaScript code use to find this button. HTML answers one question: what exists on the page.
Next, the CSS rule that sets how the button looks:
.save-btn {
background: #16a34a;
border-radius: 8px;
}
The first line picks out anything named save-btn, the background line makes it green, and border-radius rounds the corners. #16a34a is a hex code, a color written as a number so a tool or a designer can specify one exact green. CSS answers the second question: how things look.
Last, the JavaScript click handler, the lines that run when someone taps the button:
button.addEventListener("click", () => {
button.textContent = "Saved";
fetch("/save", { method: "POST" });
});
The first line tells the browser to run the next two lines whenever someone clicks the button, the second changes the label to Saved, and the third, the fetch line, sends the request that records the save. Look at the order again: the label changes before the request is sent, and no line changes it back if the request fails. Those three lines explain the opening scene exactly. The same order is why Instagram's heart turns red before your like reaches any server: the code that changes the heart runs on the phone, before the request goes out.
Every screen mixes the same three materials: HTML is the structure, what exists; CSS is the appearance, how it looks; and JavaScript is the behavior, what happens when the user acts.
In the drawing, each material has an everyday picture: HTML is the skeleton, CSS is the clothes, and JavaScript is the page's reactions.
You will not write these materials by hand. Your tools write them all the time and describe their edits as they make them, and knowing the three materials lets you follow those descriptions: edits to .html files change what exists, edits to .css files change how things look, and edits to click handlers change what the page does. Modern tools mostly work in components, reusable pieces of a screen that keep structure and behavior in one file, but inside one component the three jobs are still separate.
The obvious objection: your tools write all three
If the tools write all three materials, telling them apart can look like trivia. It stops looking that way at your first diff, the before-and-after of a change that a tool shows you when it asks you to approve its edits. One change can touch a dozen files, and sorting the edits by the three materials turns that wall of code into changes you can follow. If you cannot sort a change, you can only accept it as written, without steering it. Sorting also helps you catch a line in the wrong place: the Save button said Saved early because one behavior line ran before another, and an API key (the secret that tells an AI provider whose account to bill) pasted into frontend code is a secret in the one part of the app every user can read.
What AI apps add to the screen
The classic screen elements have been the same for a long time: buttons, forms, menus, lists, and cards. AI apps kept all of them and added new ones, because a generated answer is different from anything those classic elements were built to show: it arrives over seconds rather than milliseconds, it rests on sources, it is sometimes wrong, and it sometimes comes right before an action the app takes for you.
- The streaming block. A text area that fills in word by word as the response comes back in pieces, so the user can start reading before the model has produced the whole answer. This is why an AI chat shows its words one at a time.
- The citation chip. A small numbered marker attached to a sentence, tying the claim to its source.
- The source rail. The list of sources alongside the answer, one entry per chip, so a reader can check the original.
- Approve and undo controls. When the app is about to act (send the email, apply the edit, delete the rows), the screen shows an approve button first or an undo button afterward, so the person stays in charge.
- The working state. What the screen shows while the model runs: step labels and progress notes, so a wait of several seconds looks like work in progress instead of a frozen screen.
In the drawing, one answer card has three of these elements: lines of streaming text, two citation chips at the ends of lines, and an approve button for the person to press. Perplexity's answer screen uses most of these elements. Ask it a question and the answer fills in word by word, numbered citation chips sit at the ends of sentences, and the sources are listed alongside, one per number, so you can see which sentences rest on which sources.
Describe a screen so a tool can build it
Sometimes a tool asks what a screen should look like; more often it starts building with a layout of its own, and your job is to notice that layout and steer it. A description a tool can build from needs no detailed mockups, measurements, or hex codes. It says who is on the screen and what they came to do, and then what the user sees, in what order, and what each element does.
Your tool will keep asking you two kinds of question. "What should this look like?" is a UI question (user interface: how the screen looks, the part a screenshot captures). "What should the user do first?" is a UX question (user experience: what using the app is like over time).
Our family nutrition app FuelTheFam turns a photo of an open fridge into a shopping list, and we described its list screen to the tool this way: A parent has just photographed their fridge and is waiting. From the top: a thumbnail of their photo, then a streaming block where the list arrives item by item, a notice with a retake button if the photo was too dark to read, and a save button that asks before it saves. That one description was enough to place every element, as the drawing shows:
The tool's first draft was wrong in ways we could only judge once we saw it, and yours will be too. When you tell the tool what is wrong, it builds a second version closer to what you want. In Work with your AI coding tool and get unstuck you turn that back-and-forth into a method you can repeat.
Try it now
This drill takes about fifteen minutes; you spend nothing on the no-setup path and a few cents at most on the tooled one. You finish with a few written lines that sort one screen into the three materials.
No setup: On a laptop or desktop (phone browsers do not offer this), right-click anything on any page and choose Inspect; Safari hides the panel until you turn on its web developer features in Settings, so the quickest route is Chrome or Firefox. The panel is DevTools, the one from the opening scene: the page's HTML on one side, and on the other the CSS that styles the element you selected. Find a color value on the CSS side (Chrome labels it Styles) and change it. The page updates instantly, and when you reload, the old color comes back, because you changed your browser's own copy of the page, not the real site. Then open an AI app you use and write three lines that sort its answer screen into the three materials: what exists, how it looks, and what responds when you act.
With your tools: In an empty folder, ask Claude Code for a one-page site about anything, then describe one change the way this chapter taught: "move the heading above the image and turn the contact line into a button." Before approving, read which files it lists for changes and sort them into the three materials: changes to what exists go into HTML or component files, changes to how it looks go into CSS, and changes to what it does go into handlers, the code that runs when the user acts. Sorted this way, the diff is a short list of changes you can check instead of a wall of code. If nothing is installed yet, the Setup Clinic gets you running. Same move in Codex or Cursor: describe the change in the sidebar and sort the touched files before accepting.
Chapter Summary
- The frontend is everything users see and touch, and it runs on the user's own device, which is why a screen can change before the request reaches the server.
- Every screen mixes three materials: HTML declares what exists, CSS declares how things look, and JavaScript declares what happens when the user acts.
- You will not write the three materials by hand, but your tools describe their edits in terms of them, so sorting a diff by material turns a wall of code into changes you can steer.
- Only someone who reads the code catches a line in the wrong place: a label that changes before its request is sent, or a secret pasted into code every user can read.
- AI apps kept the classic parts and added their own: the streaming block, the citation chip, the source rail, approve and undo controls, and the working state.
- To get a screen built, describe what the user sees, in what order, and what each element does, starting with who is on the screen and what they came to do.
- What a screen should look like is a UI question, and what the user should do first is a UX question; answering them separately gives you better answers to both.
- The first draft will be wrong in ways you can only judge once you see it, and when you say what is wrong, the tool builds a next version closer to what you want.
- Secrets and rules about money or data cannot live in frontend code, because every user can read it. Next, Backend, where the real work happens shows where they live instead.
Sources
- MDN Web Docs, the HTML, CSS, and JavaScript references (last verified July 2026).
- Chrome DevTools documentation, and Apple's Safari documentation on enabling web developer features (last verified July 2026).
- Perplexity (perplexity.ai): the streaming answer, numbered citation chips, and source list describe its live product behavior (last verified July 2026).
- Instagram: the heart fills immediately on tap, observable in the app (last verified July 2026).
- FuelTheFam (fuelthefam.com), our family nutrition app; the fridge list screen description is from our build.