Since f(x)=g(x) for all by the hypothesis of the problem, it remains to show that f(x)=g(x) for all .

Suppose to the contrary that for some . Since Y is Hausdorff, we have disjoint open sets U and V containing f(x) and g(x), respectively. Since f and g are continuous, x belongs to an open set . We know that D is dense in X, which implies that every open set in X intersects a dense subset D. Thus, an open set intersects D. Let y belongs to that intersection. Since y belongs to , . Since y also belongs to D, we have f(y)=g(y) by the hypothesis of the problem. Contradiction !

Thus, for all .