Programming

Web Basics: HTML elements and links, CSS specificity and the box model

How a web page is built: HTML elements, attributes and links, CSS rules and which rule wins, and how wide a box really is. For adults starting from zero.

3 lessons, 18 steps

Get it on Google Play

How a web page is put together

Every web page is a text file with tags in it, plus CSS rules that decide how it looks. Web Basics is a short course for adults starting from zero: what a tag does, why one CSS rule beats another, and why a box turns out wider than the width you gave it.

The course has three lessons. The first is about HTML: the opening tag, content and closing tag of an element, nesting one element inside another without overlapping tags, writing an attribute with a quoted value, using heading levels in order and writing a link that jumps to a heading on another page. The second covers CSS rules: the selector, property and value, type, class and ID selectors, and what happens when two rules set the same property. You count specificity in three columns, IDs, classes and elements, and predict which rule wins. The third is the box model: content, padding, border and margin, the visible width in the standard box model, what box-sizing: border-box changes and how margins add to the space a box takes up.

Each lesson opens with a short explanation, then six steps. You type a tag, a selector or a link address, order pieces of code, pick an option, work out a width in pixels or explain a choice in a sentence or two. When your answer is off, the AI tutor first asks a question about it, then gives a hint, then a partial step. Show solution is always available, and a four-question quiz before and after each lesson shows what changed.

This is one of the editorial courses in Ai Teacher. The problems and worked solutions were written in advance, and facts were checked against the public sources listed below: MDN Web Docs and Wikipedia.

What you'll learn

  • Write HTML elements with attributes, headings and links
  • Predict which CSS rule wins from the cascade and specificity
  • Work out how wide a box is from its padding, border and margin

Lessons

  1. HTML elements, attributes and links

    6 steps, 4 min intro

  2. CSS rules, selectors and specificity

    6 steps, 4 min intro

  3. The box model and an element's width

    6 steps, 4 min intro

Counting specificity in lesson 2

Tutor: Count the specificity of the selector #footer ul .link a. Write it as IDs-classes-elements, the way p is written as 0-0-1.

You: 0-0-4

Tutor: Which pieces start with # or a dot? Do they go in the same column as ul?

You: #footer is an ID and .link is a class, so only ul and a are elements. It's 1-1-2.

Tutor: Right, 1-1-2: one ID, one class and two elements. The spaces between the pieces count for nothing.

Based on a real step from lesson 2. The tutor's wording varies, and AI can be wrong: the tutor answers from the course material and labels a reply it could not check.

Who this course is for

  • You want to make or edit a simple web page and need to know what the tags mean.
  • You changed a CSS rule, nothing happened, and you want to know which rule is winning.
  • You plan to learn JavaScript and want the HTML and CSS it works with first.
  • You would rather answer short questions with feedback than watch long tutorials.

Questions about Web Basics

Do I need to know any programming?

No. The course starts from what a tag is. The only math is adding and subtracting widths in pixels in lesson 3.

Do I build a web page in the app?

No. You read short pieces of HTML and CSS and answer questions about them: type a tag, a selector or a link address, put pieces of a line in order, pick an option or work out a width. To try the code yourself, a plain text editor and a browser are enough.

Does the course cover JavaScript or page layout?

No. The three lessons cover HTML elements and links, CSS selectors and specificity, and the box model. There is no JavaScript, flexbox or grid. For JavaScript, see JavaScript basics practice.

Is the course free?

One lesson in Ai Teacher is free. After that, a subscription opens all lessons. You can pay monthly or yearly in Google Play, and usage limits apply.

Sources

Facts and definitions were checked against these public sources. Lesson text and examples were written independently; no text was adapted.

Start Web Basics: HTML and CSS in Ai Teacher

One lesson in the app is free. Ai Teacher is available for Android on Google Play.

Get it on Google Play