# Completely regular space is hereditary

So I look online that the definition of the completely regular if whenever $E\subset X$ is closed and $x\notin E$ there is a continuous function $f:X\to [0,1]$ such that $f(x)=0$, and $f(E)=\{1\}$.

Now, on a "fact", they also say they the Tychonoff space is hereditary property. Now, I think that this follows from the fact that Tychonoff space is completely regular. So how do I show that completely regular space is hereditary if that's the case?

Let $X$ be completely regular, and let $Y\subseteq X$ be a subspace with the relative topology. Suppose that $F\subseteq Y$ is closed in $Y$ and $x\in Y\setminus F$. Then $x\notin\operatorname{cl}_XF$, so by complete regularity of $X$ there is a continuous $f:X\to[0,1]$ such that $f(x)=0$ and $f[\operatorname{cl}_XF]=\{1\}$. Now let $g=f\upharpoonright Y$, the restriction of $f$ to $Y$; $g:Y\to[0,1]$ is continuous, $g(x)=0$, and $g[F]=\{1\}$. Thus, $Y$ is completely regular.