How can I prove that $\mathrm{Spec}(B)\rightarrow\mathrm{Spec}(A)$ is continuous? 
Let $\phi:A\rightarrow B$ be a ring homomorphism. Then we can define $$f:\mathrm{Spec}(B)\rightarrow\mathrm{Spec}(A);~~~\mathfrak{p}\mapsto\phi^{-1}(\mathfrak{p})$$
I want to show that $f$ is continuous w.r.t the Zariski topology.

Therefore let me pick $\;\mathcal{O}\subset\mathrm{Spec}(A)\;$ a closed set, then this means that $\;\mathcal{O}=V(I):=\{\mathfrak{q}\in\mathrm{Spec}(A): I\subseteq \mathfrak{q}\}$ for some ideal $I$. Now $$\begin{align} f^{-1}(\mathcal{O})&=f^{-1}((V(I))\\&=\{\mathfrak{p}\in\mathrm{Spec}(B): \phi^{-1}(\mathfrak{p})\in V(I)\}\\&=\{\mathfrak{p}\in\mathrm{Spec}(B): I\subseteq \phi^{-1}(\mathfrak{p})\}\\&=\{\mathfrak{p}\in\mathrm{Spec}(B): \phi(I)\subseteq \mathfrak{p}\}\end{align}$$
But now $\{\mathfrak{p}\in\mathrm{Spec}(B): \phi(I)\subseteq \mathfrak{p}\}=V(\phi(I))$ but $\phi(I)$ does not need to be an ideal in $B$.
Is there a trick how to get an ideal in $B$ s.t. $f^{-1}(\mathcal{O})=V(\ldots)$ ?
Thanks a lot.

For any subset $S\subseteq A$ you have that $V(S)=V(\langle S\rangle)$ where $\langle S\rangle$ is the ideal generated by $S$. So what you've proven is that $f^{-1}(\mathcal O)=V(\langle \phi(I)\rangle)$ and you're done.
