a CW complex
A CW complex is a space built by gluing together simple building blocks — points, line segments, disks, balls — one dimension at a time, like assembling a model from beads, wires, and patches of fabric. Start with a scatter of points, connect some with arcs, fill in some loops with disks, plug in higher balls, and so on. This Lego-like construction is flexible enough to build essentially every space topologists care about, yet rigid enough that homotopy theory works cleanly on it.
Formally, build X by stages. Start with a discrete set X^0 of points (the 0-cells). Inductively form the n-skeleton X^n from X^{n-1} by attaching n-cells: for each cell take a closed n-disk D^n and a continuous attaching map phi: S^{n-1} (its boundary sphere) -> X^{n-1}, then glue D^n to X^{n-1} along phi. The space X is the union of all skeleta with the weak topology (a set is closed iff its intersection with each cell's closure is closed) — the 'W' in CW. The 'C' stands for closure-finite: each cell's closure meets only finitely many cells. The open n-cells are the interiors of the attached disks, and X is partitioned into its open cells. A cellular map is one sending the n-skeleton of the source into the n-skeleton of the target for every n.
CW complexes are the preferred arena for homotopy theory because the strongest theorems hold exactly here: the Whitehead theorem (a weak homotopy equivalence between CW complexes is a genuine homotopy equivalence), cellular approximation (every map is homotopic to a cellular one), and clean inductive computations of pi_1 and homology cell by cell. They also enjoy the homotopy extension property along subcomplexes, which makes cofibration arguments routine. An honest note on scope: not every topological space is a CW complex (the topologist's sine curve is not, nor are many wild fractals), but every reasonable space — manifolds, algebraic varieties, function spaces up to homotopy — is homotopy equivalent to one, which is usually all the theory needs.
The n-sphere S^n has a minimal CW structure with exactly one 0-cell and one n-cell: take a point, then attach an n-disk by collapsing its entire boundary sphere S^{n-1} to that point. Real projective space RP^n has one cell in each dimension 0, 1, ..., n, with attaching maps the double covers S^{k-1} -> RP^{k-1}.
Two cells build a sphere; one cell per dimension builds projective space — minimal CW structures.
The weak topology is essential and non-obvious: an infinite CW complex is NOT just the set-theoretic union with the subspace topology from any embedding; a function out of X is continuous iff its restriction to each cell closure is, which can differ from naive expectations on non-locally-compact examples.