[proofplan]
The strategy is direct. Since $X$ is separable, it contains a [countable](/page/Countable%20Set) [dense subset](/page/Dense%20Subset) $D$. We show that the image $f(D)$ is a countable dense subset of $Y$. Countability is immediate (the image of a countable set is countable). For density, we take an arbitrary nonempty [open set](/page/Open%20Set) $V \subset Y$, pull it back to a nonempty open set $f^{-1}(V) \subset X$ via [continuity](/page/Continuity) and surjectivity, find an element of $D$ inside the preimage, and push it forward into $V$.
[/proofplan]
[step:Form the image of the countable dense subset under $f$]
Let $D = \{d_1, d_2, \ldots\} \subset X$ be a [countable](/page/Countable%20Set) [dense subset](/page/Dense%20Subset), which exists because $X$ is separable. Define $E := f(D) = \{f(d_1), f(d_2), \ldots\} \subset Y$. Since $E$ is the image of a countable set under a function, $E$ is countable (the map $k \mapsto f(d_k)$ surjects $\mathbb{N}$ onto $E$, so $|E| \le |\mathbb{N}|$).
[/step]
[step:Verify that $f(D)$ is dense in $Y$ using continuity and surjectivity]
We show $\overline{E} = Y$ by verifying that every nonempty [open set](/page/Open%20Set) in $Y$ meets $E$. Let $V \subset Y$ be a nonempty open set.
**Surjectivity gives a nonempty preimage.** Since $f$ is surjective and $V \neq \varnothing$, there exists $y \in V$, and there exists $x \in X$ with $f(x) = y$. In particular, $x \in f^{-1}(V)$, so $f^{-1}(V) \neq \varnothing$.
**[Continuity](/page/Continuity) gives an open preimage.** Since $f$ is continuous, the preimage $f^{-1}(V)$ is open in $X$.
**Density of $D$ provides a point in the preimage.** Since $D$ is [dense](/page/Dense%20Subset) in $X$ and $f^{-1}(V)$ is a nonempty open subset of $X$, there exists $d_k \in D \cap f^{-1}(V)$.
**The image of this point lies in $V$.** Since $d_k \in f^{-1}(V)$, we have $f(d_k) \in V$. Moreover, $f(d_k) \in f(D) = E$. Therefore $E \cap V \neq \varnothing$.
Since $V$ was an arbitrary nonempty open subset of $Y$, the set $E = f(D)$ is dense in $Y$. As $E$ is both [countable](/page/Countable%20Set) and dense, $Y$ is separable.
[guided]
We need to show that $E = f(D)$ intersects every nonempty open set in $Y$. This is where both hypotheses on $f$ — continuity and surjectivity — play distinct roles.
Let $V \subset Y$ be a nonempty open set. Our goal is to find an element of $E$ inside $V$.
The first question is: does the preimage $f^{-1}(V)$ contain any points at all? If $f$ were not surjective, the set $V$ might lie entirely outside $f(X)$, making $f^{-1}(V) = \varnothing$, and the argument would collapse. But $f$ is surjective, so for any $y \in V$ there exists $x \in X$ with $f(x) = y$, giving $x \in f^{-1}(V)$. Hence $f^{-1}(V) \neq \varnothing$.
The second question is: is $f^{-1}(V)$ open? This is exactly the [topological](/page/Topology) definition of continuity: $f$ is continuous if and only if the preimage of every open set is open. Since $V$ is open in $Y$ and $f$ is continuous, $f^{-1}(V)$ is open in $X$.
We now have a nonempty open set $f^{-1}(V) \subset X$. Since $D$ is dense in $X$, the definition of density guarantees $D \cap f^{-1}(V) \neq \varnothing$. Choose $d_k \in D \cap f^{-1}(V)$. Then $d_k \in f^{-1}(V)$ means $f(d_k) \in V$, and $d_k \in D$ means $f(d_k) \in f(D) = E$. Therefore $f(d_k) \in E \cap V$, so $E \cap V \neq \varnothing$.
Since $V$ was an arbitrary nonempty open subset of $Y$, the set $E$ is dense in $Y$. Combined with the countability of $E$ established in the previous step, $Y$ is separable.
[/guided]
[/step]