Memorisely
Design Engineering

HTML vs JSX, and why components matter

Plain HTML describes one page. JSX describes a component you can reuse, vary and keep in sync across the product.

Zander Whitehurst

14 min read

HTML is the page. JSX is the component. Both end up as the same buttons and headings in the browser, and that similarity is why designers treat them as interchangeable. They are not. A page of HTML describes one screen, once. JSX describes a piece of interface you can place many times, pass different content into, and change in one file when the product changes.

That difference is the centre of design engineering. If you can only read HTML, you can review a mock that was pasted into a file. If you can read JSX, you can review whether the interface was built as a system. This article walks the same interface both ways, then stays with the syntax until the braces, the capital letters and the lists feel ordinary.

Start with the screen, not the syntax

Picture a small account header. A name, an email, and two actions.

In HTML you write the screen out in full. Every tag is something the browser already knows.

<header class="account">
  <img src="/ada.jpg" alt="" />
  <div>
    <h2>Ada Lovelace</h2>
    <p>ada@memorisely.com</p>
  </div>
  <button class="btn btn-secondary">Edit</button>
  <button class="btn btn-primary">Save changes</button>
</header>

Read it as a document. header is a region. img is an image. h2 is a heading. p is a paragraph. button is a control that can be focused and activated with a keyboard. The classes btn-secondary and btn-primary point at CSS. Nothing here is a component. If the next page needs the same header for a different person, you copy the block and edit the words.

That copy is the whole problem. The second page has its own h2, its own email, its own buttons. They look the same until someone changes one of them. I have inherited marketing sites like this. Forty buttons, thirty-eight of them almost the same, two of them missing the focus style because they were written on a Friday.

What HTML is responsible for

HTML marks up meaning, and the browser attaches behaviour for free.

  • A button receives keyboard focus, responds to Enter and Space, and shows up as a button to assistive technology.
  • An a with an href is navigation. It opens a menu of link actions, and it has a visited state.
  • An input is a field. The browser handles typing, selection, autofill and the form submit.
  • An h2 is a heading in the page outline, which is how people skip around a long screen.

A div with a click handler has none of that unless someone rebuilds it. Design engineering starts by choosing the element that already does the job. JSX does not retire this. Every component you write should end in these elements. If the component renders a div where a person expected a button, the component is wrong even when the pixels match.

JSX is that document, given a name

JSX looks like HTML written inside JavaScript. You use it to describe the same tree, then wrap the tree in a function so it has a name.

function AccountHeader({ name, email, avatar }) {
  return (
    <header className="account">
      <img src={avatar} alt="" />
      <div>
        <h2>{name}</h2>
        <p>{email}</p>
      </div>
      <Button variant="secondary">Edit</Button>
      <Button variant="primary">Save changes</Button>
    </header>
  );
}

The screen that used to be a copy is now a call.

<AccountHeader
  name="Ada Lovelace"
  email="ada@memorisely.com"
  avatar="/ada.jpg"
/>

A second person is a second call, with different values. The structure lives in one function. Change the order of the buttons, add a status, fix the focus ring, and both people get it.

Two kinds of tag sit in that function, and the capital letter is how you tell them apart.

  • <header>, <img>, <h2> and <p> are HTML. Lowercase. The browser will receive them almost unchanged.
  • <Button> and <AccountHeader> are components. Capitalised. They are function calls. The browser never sees the name Button. It sees whatever that function returns, which should be a real <button>.
function Button({ variant = "primary", children }) {
  return (
    <button className={`btn btn-${variant}`}>
      {children}
    </button>
  );
}

<Button variant="primary">Save changes</Button> runs Button, passes variant and the label in, and gets a <button class="btn btn-primary"> back. That last step is a build tool, not the browser. You write JSX. The tool turns it into JavaScript function calls. Those calls produce the HTML the browser paints. When a preview looks right and the page is still a pile of divs, the tool did its job and the component structure never existed.

The same tree, three layers

It helps to keep three layers in your head while you read a file.

What you readWhat it isWhat the browser gets
<Button>Your componentWhatever Button returns
<button>HTML elementA real button in the page
classNameThe JSX name for classclass on the element
{name}A JavaScript valueThe text Ada Lovelace
JSX is the authoring syntax. HTML is the document. The browser only sees the document.

If you are reviewing a generated file, find the capitalised tags first. Their absence is the signal that you have a page of HTML with a .jsx extension.

The syntax that trips people on first read

JSX had to be valid inside a JavaScript file, so a handful of HTML names moved. The meaning did not.

HTMLJSXWhy it changed
classclassNameclass is already a word in JavaScript
forhtmlForfor is already a loop
checkedchecked={true}Attributes can be JavaScript values, not only strings
<!-- note -->{/* note */}Comments follow JavaScript
<input><input />Every tag is closed, so the tree is unambiguous
The browser still receives HTML. JSX is the syntax for writing that HTML inside a component.

className is the one you will see every day. It is still the HTML class. You write className="account" and the element arrives in the browser as class="account". The rename exists so the file can also contain JavaScript, where class already means something else.

htmlFor is the same kind of rename. In HTML a label uses for to point at an input id. In JSX that attribute is htmlFor, because for is a loop. The label still points at the input. A generated form that uses for on a label inside a component will not connect them.

Every tag is closed. HTML lets you write <input> and <img> and move on. JSX asks you to close them, <input /> and <img />, so the tree has an obvious end. A component that returns two sibling elements without a parent is also illegal. Wrap them in a <div>, a <header>, or a fragment, <>...</>. The fragment groups elements without adding a node to the page.

Curly braces are the door into JavaScript

Inside JSX, curly braces leave the markup and evaluate JavaScript. Whatever that expression produces gets printed, or passed, or used as a condition.

<h2>{name}</h2>
<img src={avatar} alt="" />
<button disabled={isSaving}>{isSaving ? "Saving…" : "Save changes"}</button>

Read each pair of braces as "the value of". {name} is the value of name. {avatar} is the address stored in avatar, not the letters a-v-a-t-a-r. {isSaving ? "Saving…" : "Save changes"} is one of those two strings, chosen by the value of isSaving.

HTML has no equivalent. To show "Saving…" you would ship two buttons and hide one of them from somewhere else, or you would rebuild the button in a script every time the state changed. The braces are why a component can be the rule for a screen instead of a photograph of one.

A few shapes are worth recognising on sight.

  • {children} is whatever a caller put between the tags. <Button>Save changes</Button> makes children the text "Save changes". <Button><Icon /> Save changes</Button> makes children the icon and the text. This is the slot.
  • {items.length} is a number. {items.length === 0 ? "Nothing here" : "Recent"} is a string chosen from that number.
  • className={isActive ? "tab tab-active" : "tab"} is a class that follows state. The HTML class is still a string by the time it reaches the browser. The expression only decides which string.

Braces do not print objects or lists on their own in a useful way. {user} where user is { name, email } will not render a neat header. You print the fields you mean, {user.name}, or you pass user into a component that knows how to render it.

Props are the labels on the call

A prop is a named value you pass into a component. In the account header, name, email and avatar are props. In the button, variant and children are props.

<Button variant="secondary">Edit</Button>
<Button variant="primary" disabled={isSaving}>Save changes</Button>

variant="secondary" is a string, so it can be written in quotes, the way an HTML attribute is written. disabled={isSaving} is a JavaScript value, so it goes in braces. disabled="false" would be the string "false", which is still truthy, and the button would stay disabled. That single mix-up is the most common bug I see when designers start editing generated components. A boolean, a number, or anything that is not a fixed string goes in braces.

The set of props is the contract. variant should only accept the values you designed, "primary" and "secondary", rather than any class someone feels like typing. How to shape that contract is covered in designing component props. The Figma version of the same idea, instances and variant properties, is in React components for designers.

One definition, then the moments it has to cover

A snippet of HTML is a picture of a screen at one moment. A component is the rule for every moment you care about.

Variants stay attached to the thing they vary. In the HTML file, btn-primary and btn-secondary are class names anyone can mistype. In JSX, variant is an argument to Button. A typo becomes an error in one file, or it falls back to the default. The class string is built inside Button, so a screen cannot invent btn-primary-large-green without editing the component on purpose.

State has somewhere to live. A disclosure that is open, a tab that is selected, a field that failed validation. In HTML you represent the result: aria-expanded="true", a class of is-open. Something else has to flip those attributes when the person clicks. In a component, the behaviour sits next to the markup that depends on it.

function Disclosure({ title, children }) {
  const [open, setOpen] = useState(false);
  return (
    <div>
      <button aria-expanded={open} onClick={() => setOpen(!open)}>
        {title}
      </button>
      {open ? children : null}
    </div>
  );
}

Walk it once. open starts false. The button's aria-expanded is false, and the children are not rendered, because open ? children : null chooses null. A click calls setOpen(!open), which sets open to true. React renders the function again. This time the button reports expanded, and the children appear. You did not write a second copy of the disclosure. You wrote the rule, and the state picks which part of the rule is visible.

The HTML is still doing the accessible part. button and aria-expanded are platform features. {open} only supplies the current value. A component that skips them to draw a div has thrown away the reason HTML exists. The platform owns focus, semantics and the accessibility tree. The component owns reuse, variants and the states your product adds.

Data can shape the screen. A list of transactions in HTML is a list you wrote by hand, one <li> per row you happened to design. A list in JSX is the data walking through one row component.

{transactions.map((transaction) => (
  <TransactionItem key={transaction.id} transaction={transaction} />
))}

map walks the array. For each transaction it returns one TransactionItem. key tells React which row is which when the list changes, so it updates the right one. Add a transaction and the screen grows a row. You designed the row once. This is the point where a static export of a Figma frame stops being enough. The frame showed three rows. The product has as many as the account has.

An empty account is the same component, taking a different path.

{transactions.length === 0 ? (
  <p>No transactions yet</p>
) : (
  transactions.map((transaction) => (
    <TransactionItem key={transaction.id} transaction={transaction} />
  ))
)}

In HTML, the empty state is a second page you remember to design, or it is a paragraph you forget to delete when the data arrives. In JSX it is a branch next to the list.

A file you should be able to read cold

This is the shape of a small component file. Read it from the function arguments down to the tags.

function PlanCard({ name, price, current }) {
  return (
    <article className={current ? "plan plan-current" : "plan"}>
      <h3>{name}</h3>
      <p>{price}</p>
      <Button variant={current ? "secondary" : "primary"}>
        {current ? "Current plan" : "Choose " + name}
      </Button>
    </article>
  );
}
  • PlanCard is a component, because of the capital.
  • name, price and current arrive from whoever renders <PlanCard>.
  • article, h3 and p are HTML.
  • className is the class. The braces choose plan plan-current when current is true.
  • {name} and {price} print those props.
  • Button is another component. Its variant and its label both depend on current.

Used twice:

<PlanCard name="Starter" price="£12" current={false} />
<PlanCard name="Team" price="£32" current={true} />

Two articles, one definition. Starter gets a primary button labelled "Choose Starter". Team gets a secondary button labelled "Current plan" and the current class. If pricing later needs a badge, you add it inside PlanCard and both plans grow it.

What goes wrong when a page pretends to be a component

Generated UI fails in a small number of ways. Once you can see them, review gets much faster.

The file is HTML wearing a JSX extension. Tags are lowercase, labels are baked into the elements, and the same button markup appears ten times. Rename is a find-and-replace. There is no Button to fix once.

Everything is a div. The preview matches the frame, and none of it is a button, a link, a heading or a field. Keyboard users get a picture. The fix is to put the HTML element back inside the component, not to add another class.

Strings where values belong. disabled="false", count="3" passed into something that does arithmetic, checked="checked" copied from HTML when the JSX wanted checked={true}.

Components that fetch their own screen. A PlanCard that requests /api/plan cannot be shown in a list, in a modal, or with sample data. Pass name, price and current in. Let the page do the fetching.

One component for the whole page. SettingsPage with four hundred lines of JSX is a document again. Pull out PlanCard, AccountHeader and Button at the point where a block repeats or has its own state. The page should read as a list of those names.

How to practise

Take one screen from a product you know and rewrite only the header, by hand, in both forms.

  1. Write it as HTML. Use real elements: header, h2, button, a, img.
  2. Circle anything that would change per person, per plan or per state. Those circles are props.
  3. Wrap the HTML in a function. Replace the circled words with {prop}.
  4. Replace any button you repeated with <Button>, and keep a real <button> inside that component.
  5. Render it twice, with two different sets of props, and change one thing inside the function to confirm both copies follow.

Then open a generated file and ask the review questions.

  1. Are repeated controls real components, or copies of the same markup?
  2. Do capitalised tags (Button, Stack, Text) carry the visual decisions, with lowercase tags reserved for meaning?
  3. Are labels, variants and icons coming in as props, rather than baked into forty slightly different buttons?
  4. Does each interactive element use the HTML element that already has the behaviour?

The HTML and CSS foundations are still the floor. JSX does not replace them. It gives you a way to use them more than once, and to keep every use in agreement when the product moves. A design engineer is accountable for the screen the browser paints and for the structure that will produce the next one without starting from a blank document.

Keep reading

View all
View all

Optimize your AI for better experiences, not AI slop.

View all

AI Prototyping Skills

Prototype with AI using clean UI patterns and guardrails so flows feel product-grade, not generic template slop.

$99

AI UI Motion Skills

Motion and micro-interaction patterns that make AI-built UI feel designed, polished, and trustworthy in real products.

$99

Fix AI Slop Skills

Spot AI slop early and fix type, spacing, and components so your product looks intentional, not like a template.

$99

AI Responsive Design Skills

Responsive layout patterns for rails, sidebars, and breakpoints so AI-generated UI adapts cleanly from narrow to wide.

$99

AI Dark Mode Skills

Dark theme tokens, contrast, and surfaces that keep AI-generated UI readable and product-grade, not flat gray on black.

$99

AI Color Token Skills

Neutral and primary ramps with clear steps so AI palettes stay systematic, not a random set of accent hex codes.

$99
View all