If $X$ is a CW complex, then the path components of $X$ are the components of $X$. I'm self-learning Algebraic Topology from Rotman's Introduction to Algebraic Topology and I've come across this problem:

If $X$ is a CW complex, then the path components of $X$ are the components of $X$.

The proof states:  If $A$ is a path component of $X$ and $Y$ is a component of $X$ containing $A$ and since $A$ is both open and closed, then it follows that $A=Y$.
How does it follows here?  I don't see the connection.
 A: I think one can show that a CW-complex is locally path-connected.
See here, looks non-trivial or these notes, this looks more accessible
And in a locally path-connected space $X$ path-components are the same as components:
First observe that if $P_x$ is the path-component of $x$, $P_x$ is open in $X$ (see here e.g.). 
Directly: let $y \in P_x$, then $y$ has a path-connected neighbourhood $N_y$. But all points in $P_x \cup N_y$ can be reached via a path from $x$ (for $N_y$ we go via $y$ and use the path-connectedness of $N_y$, so by maximality: $P_x \cup N_y \subseteq P_x$ which implies $N_y \subseteq P_x$, so $y$ is an interior point of $P_x$; as $y$ was arbitrary, $P_x$ is open.
As the whole space $X$ is a disjoint union of its path-components all path-components are closed as well (the complement of a path-component is also open, as a union of the other path-components).
If $C_x$ is the component of $x$, then $P_x \subseteq C_x$ as $P_x$ is connected and contains $x$, and $C_x$ is the maximal set with that property. As $P_x$ is clopen in $X$ and $C_x$ is connected, the inclusion cannot be proper, or $P_x$ and its complement would disconnect $C_x$. So $P_x = C_x$.
A: A subset $A$ of a topolgical set $X$ which is open and closed is a union of connected components. To see this, consider $x\in A$ and $C$ is connected component, $C\cap A$ is closed and $C\cap (X-A)$ is also closed, you deduce that $C\cap (X-A)$ is empty since $C$ is connected, henceforth $C\subset A$.
A: You can also just prove this directly from the definition of a CW-complex.  By "cell" I will always mean "closed cell", i.e. the image of the characteristic map of a cell.  Note that each cell is path-connected, being the continuous image of $\Delta^n$ for some $n$.  Now define an equivalence relation $\sim$ on cells by saying $a\sim b$ iff there exist cells $e_0,e_1,\dots,e_n$ with $e_0=a$, $e_n=b$, and $e_i\cap e_{i+1}\neq \emptyset$ for $i=0,\dots,n$.  Note that in that case, the union $\bigcup e_i$ is path-connected, so $a$ and $b$ are in the same path component of $X$.
Now for each equivalence class $S$ of cells under $\sim$, consider the set $C_S\subseteq X$ which is the union of all the elements of $S$.  By the observation above, $C_S$ is path-connected.  On the other hand, I claim each $C_S$ is open.  Indeed, any cell which intersects $C_S$ is an element of $S$ and therefore is entirely contained in $C_S$, so the inverse image of $C_S$ under the characteristic map of any cell is either empty or the entire space, and in particular is open.  So the sets $C_S$ form a partition of $X$ by open sets.  Thus any connected component of $X$ is contained in some $C_S$.  But since each $C_S$ is path-connected, this means the sets $C_S$ themselves are the connected components of $X$, and also the path-components of $X$.
