Connected Set and Subset I am a student who begins to learn topology. Here is one question that confused me a lot.

Let $E_1 \subset \mathbb{R}$ and $E_2 \subset \mathbb{R}$, and define $E=E_1 \times E_2 \subset \mathbb{R}^2$. Prove that $E$ is connected if and only if the sets $E_1$ and $E_2$ are connected.

Thank you for any help!!
 A: HINT
First assume $E_1$ is disconnected. Can you prove $E$ is disconnected by using the same discontinuity?
Now assume $E$ is disconnected. Can both $E_1$ and $E_2$ be connected?
A: If $E_1 \times E_2$ is connected, since the projections $\pi_1, \pi_2$ are continuous, $E_1 = \pi_1(E_1\times E_2)$ and $E_2 = \pi_2(E_1\times E_2)$ are connected. 
Reciprocally, suppose without loss of generality that $E_1$ and $E_2$ are connected. Now, I'll leave you to show that $E_1\times\{y\}$ and $\{x\}\times E_2$ are connected for each $x \in E_1, y \in E_2$. We have then described $E_1 \times E_2$ as a union of connected sets which, pairwise, are non-disjoint:
$$ 
E_1 \times E_2 = \big(\bigcup_{y \in E_2} E_1 \times \{y\}\big) \ \cup \big(\bigcup_{x\in E_1}\{x\}\times E_2\big) 
$$
This completes the proof, because of the following result:

Proposition. If $A \subseteq \mathbb{R^2}$ is the union of pairwise non-disjoint connected sets, it is connected.

Proof. Let $A = \bigcup_{i\in I}A_i$ with each $A_i$ connected and $A_i \cap A_j \neq \emptyset \ (\forall \ i,j \in I)$. Suppose that, on the contrary, $A$ is not connected and there exists a continuous non-constant mapping $\phi:A \to \{0,1\}$. In particular, there exist $a,c \in A$ with $\phi(a) = 0, \phi(c) = 1$. Now, since $A = \bigcup_{i \in I}A_i$, there exists $i,j \in I$ with $a \in A_i, \ c \in A_j$, and by hypothesis there also exists $b \in A_i \cap A_j$. Now,
$$
1 = |\phi(a) - \phi(c)| \leq |\phi(a) - \phi(b)| + |\phi(b) + \phi(c)| = \\ = | \ \phi\restriction_{A_i}(a) - \phi\restriction_{A_i}(b) \ | + | \ \phi\restriction_{A_j}(b) + \phi\restriction_{A_j}(c) \ | = 0
$$
which is absurd, so $A$ must be connected (here I use that restricting a continuous function leaves us with a continuous function, and the connection of $A_i$ and $A_j$ which makes each restriction constant).
This result can be easily extended to any metric space, replacing the absolute value part for the distance you're working with and $\mathbb{R}^2$ with the metric space. I haven't studied topology yet, but this should be true as well for topological spaces.
