# Continuity property for a closed set

If $$A$$ and $$B$$ are topological spaces and $$f:A\to B$$ a continuous map and $$U$$ in $$B$$ a closed set, why is $$f^{-1}(U)$$ closed in $$A$$? I know that preimage of an open set needs to be open.

$$f^{-1}(U)^{c}=f^{-1}(U^c)$$, which is open as $$U^c$$ is open(as $$U$$ is closed). Hence $$f^{-1}(U)$$ being complement of an open set, is closed.