Given a metric space $(X,d)$, how to prove that the function $d \colon X \times X \to \mathbf{R}$ is continuous?
If we take any two arbitrary real numbers $a$ and $b$ such that $a < b$, then we need to show that the set $d^{-1} (a,b)$ given by
$$ d^{-1} (a,b) := \{ (x, y) \in X \times X | a < d(x,y) < b \} $$
is open in the product topology on $X \times X$.
A basis for this product topology is the collection of all cartesian products of open balls in $(X,d)$.