Blog / Build with AI /

HTML, CSS and JavaScript explained for AI builders

When you ask AI to build a web page, it hands you three kinds of code that look like a foreign language. HTML. CSS. JavaScript. You paste them in, they work, and you feel slightly like you are operating a machine you do not understand.

You do not need to become a developer. But a basic picture of what each one does makes you a far better builder, because you can say “change the CSS” instead of “make it look different”, and you can tell when the AI has put something in the wrong place.

The house analogy

Think of a web page as a house.

  • HTML is the structure: walls, rooms, doors, windows. It says what is on the page.
  • CSS is the decoration: paint, furniture, layout, lighting. It says how things look.
  • JavaScript is the electrics and plumbing: light switches, doorbells, taps. It says what happens when someone does something.

Remove the CSS and the house is still standing, just bare. Remove the JavaScript and the house is fine, but nothing responds. Remove the HTML and there is nothing to decorate.

HTML: what is on the page

HTML is made of elements, written with tags. A heading, a paragraph, an image, a link, a button.

<h1>My shop</h1>
<p>Handmade wallets, made to last.</p>
<a href="/wallets/">See the wallets</a>

Each element has an opening tag and usually a closing one. Some carry attributes that add detail: the href says where a link goes, an alt describes an image.

Why it matters to you:

  • Meaning. Using the right element (a real <h1> for the main heading, a <button> for a button) helps search engines and people using screen readers. AI sometimes uses a plain <div> for everything. Ask for proper elements. Building accessible tools with AI goes into this.
  • Structure. Pages are nested boxes. A list holds items; a section holds headings and paragraphs. When something appears in the wrong place, the nesting is usually why.

If you run a website, you already know HTML in another form: it is what the visual editor in WordPress or Shopify writes for you.

CSS: how it looks

CSS is a set of rules. Each rule picks something on the page and says how it should look.

h1 {
  color: #222222;
  font-size: 2rem;
}

.button {
  background: #0a7;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
}

The first rule styles every h1. The second styles anything given the class button. A class is a label you attach to elements in the HTML, so CSS can find them.

What to know:

  • Selectors (the part before the braces) decide what is styled. Mistakes in selectors are why a change “does nothing”.
  • Cascade is the C in CSS. When two rules disagree, the more specific or later one wins. This is why AI-written CSS sometimes fights with your theme’s CSS.
  • Layout tools such as flexbox and grid arrange things in rows and columns. If you want elements side by side or centred, ask for them by name.
  • Responsive design makes a page adapt to screen size, using rules that only apply below a certain width. Always ask AI to make the layout work on phones. Many of your visitors will be on one.

CSS is also where most tweaks happen. Colours, spacing, fonts, sizes: these are small, safe, reversible changes. They are a good first thing to do yourself.

JavaScript: what it does

JavaScript runs in the browser and reacts to things: a click, a typed letter, a page finishing loading, a timer.

const button = document.querySelector('.button');

button.addEventListener('click', function () {
  alert('Thanks for clicking!');
});

This finds the button, then waits for a click, then shows a message. That pattern (find an element, listen for an event, respond) is the core of nearly everything: opening menus, validating forms, filtering lists, loading more results.

JavaScript can also change the page. It can add elements, edit text, hide things, fetch data from a server. That power is also what makes it the riskiest of the three. A typo in HTML looks wrong. A bug in JavaScript can break forms or stop a checkout.

What a web app is made of, explained simply and where your code runs: browser, server and your computer will fill in the picture.

How the three work together

A real example, a “show more” button:

  1. HTML provides the button and the hidden paragraph.
  2. CSS hides the paragraph by default and styles the button.
  3. JavaScript listens for the click and reveals the paragraph.

When AI builds this, it will often put all three in one file. That is fine for a small tool. For a larger one, keeping them in separate files makes each easier to find and change. See files, folders and projects: organising AI-built code.

Telling AI which one to change

This is the practical payoff. Compare:

The page looks bad on my phone.

with

The two columns in the product section should stack vertically on screens narrower than 600px. Change only the CSS.

The second tells the AI which layer to touch, what the problem is and what to leave alone. You will get a short, safe change, instead of a rewrite of your entire page.

Similarly:

  • “Add a button” is HTML.
  • “Make the button green and rounded” is CSS.
  • “Make the button copy the link” is JavaScript, with a little HTML for the button.

When something goes wrong, ask which layer is responsible:

  • Wrong content or missing element? HTML.
  • Wrong look or layout? CSS.
  • Something does not respond or happens wrongly? JavaScript.

Common myths

“JavaScript is the same as Java”

It is not. The names are a historical accident.

“I need to learn all three before building anything”

No. Learn to read them, change small things, and ask the AI to explain the rest. Learning to code in the age of AI: still worth it? and how much coding do you need to know to build with AI look at how much is enough.

“If it works, it’s fine”

Working is the start. Pages built carelessly can be slow, inaccessible or fragile. Making AI-built sites fast and SEO basics for sites built with AI are good follow-ups.

“Frameworks make this irrelevant”

React and similar tools produce HTML, CSS and JavaScript in the end. The ideas underneath stay the same.

A mini exercise

Open any simple web page, right-click and choose Inspect. Click on a heading in the panel. You will see its HTML, and beside it the CSS rules that style it. Change a colour value in the panel and watch the page change. Nothing is saved, so you cannot break anything.

Ten minutes of this teaches more than an hour of reading.

Key takeaways

  • HTML is structure, CSS is looks, JavaScript is behaviour.
  • Name the layer when you ask AI for a change.
  • Most visual tweaks are CSS, and low risk.
  • JavaScript carries the most risk, so test it.
  • You only need enough to read the code and direct the AI.

Pick one thing on your own site that annoys you. Is it an HTML, CSS or JavaScript problem?