If two continuous maps into a Hausdorff space agree on a dense subset, they are identically equal [duplicate]

Let $f, g : X \to Y$ be continuous functions. Assume that $Y$ is Hausdorff and that there exists a dense subset $D$ of $X$ such that $f(x) = g(x)$ for all $x \in D$. Prove that $f(x) = g(x)$ for all $x \in X$.

Here is what I have so far,

Proof:
Let $f : X \to Y$ and $g : X \to Y$ be continuous and suppose that $f(x)=g(x)$ for some dense $D\subset X$. Let $x \in X$, since $D$ is a dense subset of $X$, $x \in \mathrm{Cl}(D)$. I'm unsure how to proceed from here.


When we have that $f(x)\neq g(x)$ then there exists opens $U_f$ and $U_g$ such that $U_f\cap U_g=\emptyset$, here we use the Hausdorff condition. Now $A:=f^{-1}(U_f)\cap g^{-1}(U_g)$ is an open since $f,g$ are continuous. Then we have that on $A$ the functions do not coincide. This contradicts the fact that they coincide on a dense subspace.

Edit: Here we have that $U_f$ is an open containing $f(x)$ and similarly $U_g$ contains $g(x)$.


$Y$ being Hausdorff is equivalent to the diagonal $Δ = \{(y,y);~y ∈ Y \} ⊂ Y × Y$ being closed.

The map $〈f,g〉\colon X → Y × Y$ is continuous and has $〈f,g〉(D) ⊂ Δ$. By continuity, you get $$〈f,g〉(\overline{D}) ⊂ \overline{Δ}.$$