There are a few proofs out there that involve open sets, but I was wondering if my proof using limits was correct. Here it is:
Proof. Let $x\in X$. Since $D$ is dense in $X$, there is a sequence $\{x_n\}_{n=1}^\infty$ in $D$ so that $x_n\to x$. Hence $f(x_n)=g(x_n)$. Since limits in a Hausdorff space are unique, and $f$ and $g$ are continuous, this implies that $$ f(x)=\lim_{x_n\to x} f(x_n)=\lim_{x_n\to x} g(x_n)=g(x). ~~~\square$$
Is this correct? I believe this works in $\mathbb{R}$, but my main concern was where to use Hausdorfness.
If you aren't familiar with nets, here's how you can approach the general case: suppose for a contradiction there were $x\in X$ with $f(x)\neq g(x)$; since $Y$ is Hausdorff you can take disjoint open neighborhoods $V$ and $W$ of $f(x)$ and $g(x)$, and then $f^{-1}(V)$ and $g^{-1}(W)$ are both open neighborhoods of $x$, as then is $f^{-1}(V)\cap g^{-1}(W)$. Since $D$ is dense in $X$ you can find some $d\in f^{-1}(V)\cap g^{-1}(W)\cap D$, but then the element $y:=f(d)=g(d)$ is inside $V\cap W=\emptyset$ giving a contradiction.