HTML for Gadgets, lesson 2 of 9

Your First Page: the Skeleton of Every Gadget Page

beginner5 min readFree lesson

Introduction

Every page your ESP32 sends has the same skeleton. Learn it once and you can reuse it in every project. Today you'll write that skeleton and put a heading and some words on it.

HTML is the skeleton, CSS the clothes and JavaScript the nervous system

HTML (HyperText Markup Language) gives a page its structure, like a skeleton. CSS is the clothes (colours and sizes), and JavaScript is the nervous system (things that move or react). For gadget pages, HTML does most of the work.

Working principle

HTML is made of tags. Most come in pairs: an opening tag like <h1> and a closing tag like </h1>, with a forward slash. Whatever is between them gets that meaning.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My Smart Room</title>
</head>
<body>
  <h1>My Smart Room</h1>
  <p>Hello! This page lives inside my ESP32.</p>
  <p>Soon it will switch my <b>light</b> and <b>fan</b>.</p>
</body>
</html>
TagNameWhat it does
<h1> to <h6>HeadingsBig to small titles
<p>ParagraphA block of text
<b>BoldMakes words bold
<img src="…">ImageShows a picture (src says which file)

Don't worry about the two <meta> lines yet. Lesson 3 explains them.

What you'll need

  • A web browser (Chrome, Edge, Firefox or Safari).
  • A text editor: VS Code or Sublime Text. Or just use the playground below.

Try it

Change the heading to your own room's name, then add another <p> line.

On the phone

Change the heading to your own room's name, then add another <p> line.

To try it on your computer, save the code as first_page.html and double-click it. You can also download the original activity files.

Check what you learnt

  1. Which part of the page holds everything you see on the screen?

  2. How is a closing tag different from an opening tag?

  3. Which tag makes the biggest heading?

Conclusion

  • Every gadget page has the same skeleton: html, head and body.
  • Tags come in pairs, and the closing tag has a /.
  • h1 and p are enough to put a title and words on the page.

What next?

Make it fit the phone: why the <meta name="viewport"> line matters on a phone.