[proofplan]
We argue by contradiction. If $f(X)$ were disconnected, pulling back the two open pieces of the disconnection via $f$ would produce a disconnection of $X$, contradicting its [connectedness](/page/Connectedness).
[/proofplan]
[step:Pull back a hypothetical disconnection of $f(X)$ to disconnect $X$]
Suppose for contradiction that $f(X)$ is not connected. Then $f(X) = A \cup B$ with $A, B$ open in the [subspace topology](/page/Subspace%20Topology) on $f(X)$, non-empty, and disjoint.
Define $U = f^{-1}(A)$ and $V = f^{-1}(B)$. Since $f: X \to Y$ is continuous and $A, B$ are open in $f(X)$, we verify that $U$ and $V$ are open in $X$: there exist open sets $\widetilde{A}, \widetilde{B} \subseteq Y$ with $A = f(X) \cap \widetilde{A}$ and $B = f(X) \cap \widetilde{B}$, so $U = f^{-1}(A) = f^{-1}(f(X) \cap \widetilde{A}) = f^{-1}(\widetilde{A})$ (since $f(X)$ contains all values of $f$), which is open by [continuity](/page/Continuity) of $f$. Similarly $V$ is open.
The sets $U$ and $V$ are non-empty (since $A$ and $B$ are non-empty subsets of $f(X) = \operatorname{im}(f)$), disjoint (if $x \in U \cap V$ then $f(x) \in A \cap B = \varnothing$, a contradiction), and satisfy $U \cup V = f^{-1}(A \cup B) = f^{-1}(f(X)) = X$. This is a disconnection of $X$, contradicting the assumption that $X$ is connected. Therefore $f(X)$ is connected.
[guided]
The structure of the argument is: assume $f(X)$ is disconnected, use continuity to transfer the disconnection to $X$, and derive a contradiction.
Suppose $f(X) = A \cup B$ with $A, B$ open in $f(X)$, non-empty, and disjoint. We set $U = f^{-1}(A)$ and $V = f^{-1}(B)$ and check all four conditions for a disconnection of $X$:
**Open**: Since $A$ is open in the subspace topology on $f(X)$, there exists an [open set](/page/Open%20Set) $\widetilde{A} \subseteq Y$ with $A = f(X) \cap \widetilde{A}$. Every element of $U$ maps into $f(X)$ (by definition of $f$) and into $\widetilde{A}$ (by definition of $U$), so $U = f^{-1}(\widetilde{A})$, which is open in $X$ by continuity. Similarly for $V$.
**Non-empty**: Since $A \neq \varnothing$ and $A \subseteq f(X)$, there exists $y \in A$ with $y = f(x)$ for some $x \in X$, giving $x \in U$. Similarly $V \neq \varnothing$.
**Disjoint**: If $x \in U \cap V$, then $f(x) \in A \cap B = \varnothing$, which is impossible.
**Cover $X$**: Every $x \in X$ has $f(x) \in f(X) = A \cup B$, so $x \in f^{-1}(A) \cup f^{-1}(B) = U \cup V$.
All four conditions hold, so $X = U \cup V$ is a disconnection, contradicting connectedness of $X$. The key input is that preimages under continuous maps preserve openness — this is what allows topological properties to transfer from the codomain to the domain.
[/guided]
[/step]