Is there any example of space not having the homotopy type of a CW-complex?
Solution 1:
Since you are now asking for a connected example, here is a justification for Harry's example:
Lemma. The Hawaiian earring $H$ is not homotopy-equivalent to any CW-complex $X$.
Proof. Suppose to the contrary, $f: H\to X$ is a homotopy-equivalence. Since $H$ is compact, so is $f(H)$. Hence, $f(H)$ is contained in a finite subcomplex $Y$ of $X$. In particular, the subgroup $f_*(\pi_1(H))< \pi_1(X)$ is contained in a finitely generated subgroup (the image of $\pi_1(Y)$ under the map $\pi_1(Y)\to \pi_1(X)$) and, hence, is at most countable. However, $\pi_1(H)$ is known to be uncountable, see http://en.wikipedia.org/wiki/Hawaiian_earring. Therefore, $f$ does not induce a monomorphism of fundamental groups and, hence, cannot be a homotopy-equivalence. qed
Example. Local contractibility is not preserved by homotopy equivalence. Consider a compact subset $C$ of $R^2$ which is the union of countably many unit segments $[0z_n], n\in {\mathbb N}$, in the plane, which all have the origin $0\in R^2$ as an endpoint. Then $C$ is not locally contractible at any accumulation point $z\in C$ of the set $Z=\{z_n: n\in {\mathbb N}\}$. On the other hand, the set $C$ is clearly contractible (as any starlike subset of the Euclidean plane). Thus, $C$ is homotopy-equivalent to the point and point is, of course, locally contractible.
In particular, Harry's reasoning is insufficient to prove that $H$ is not homotopy-equivalent to a CW complex.
Solution 2:
The Hawaiian earring does not have the homotopy type of a CW-complex. I'm not sure of any completely general method for determining of a space has the homotopy type of a CW-complex.
Edit: The Hawaiian earring not having the homotopy type of a CW-complex comes from it not being locally contractible, which every CW-complex must be. To demonstrate that it isn't locally contractible, consider an open neighbourhood of the origin and observe that any such neighbourhood will contain all but finitely many circles. This is homeomorphic to the entire earring, which is not contractible.
Solution 3:
The cantor set is one.
It is s compact space with infinitely many connected components, and compact CW spaces can only have finitely many.
Solution 4:
Here are two more examples similar to Mariano's answer (together with Moishe's comment).
Example 1. Let $A \subset \mathbb{R}$ be $$A = \{ \frac{1}{n} \mid n \in \mathbb{N} \} \cup \{0\}.$$ Let $f \colon A \to Y$ be a map to a CW complex $Y$. Then the point $f(0) \in Y$ has a path-connected neighborhood $V \subseteq Y$, and there is a neighborhood $U$ of $0 \in A$ satisfying $f(U) \subseteq V$. Hence, $f$ induces a map on path components $f_* \colon \pi_0(A) \to \pi_0(Y)$ which is not injective. In particular, $f$ is not a homotopy equivalence.
Example 2. Let $T \subset \mathbb{R}^2$ be the topologist's sine curve $$T = \{ (x, \sin \frac{1}{x}) \mid x \in (0,1] \} \cup \{(0,0)\}.$$ Let $f \colon T \to Y$ be a map to a CW complex $Y$. Since $T$ is connected, $f(T)$ is connected. Since the path components of $Y$ agree with its connected components, $f(T)$ lies within one path component of $Y$. Hence, $f$ induces a map on path components $f_* \colon \pi_0(T) \to \pi_0(Y)$ which is not injective.
Remark. Example 2 holds more generally for any space $X$ with some connected component that contains more than one path component. In fact, the property that connected components agree with path components is invariant under homotopy equivalence.