Prove that $E$ is disconnected iff there exists two open disjoint sets $A$,$B$ in $X$

Let $(X,d)$ be a metric space. Prove that $E$ is disconnected iff there exists two open disjoint sets $A$,$B$ in $X$ such that $E\cap A\neq\emptyset, E\cap B\neq \emptyset$ and $E\subset A\cup B$.

I’m not sure how to begin, so let me just start by pointing some stuff out from the question that I noticed, and my knowledge as of now. (Hopefully it’ll be useful.)

I know that the definition of separated means that I have $A,B\subset X$, for which $A\cap \bar{B}=\emptyset=\bar{A}\cap B$, where the bar above the set denotes its closure.

And I know that the definition of connected set means for $E\subset X$, $E$ is connected if $E$ is not the union of two non-empty separated sets, so a disconnected set would be for $E\subset X$, $E$ is disconnected if it is the union of two separated sets (which are both non-empty).

Any hints as to how to begin would be appreciated. Thank you.

Solutions Collecting From Web of "Prove that $E$ is disconnected iff there exists two open disjoint sets $A$,$B$ in $X$"

Paraphrased from my answer here: If there are disjoint sets $A,B$ which intersect $E$ and such that $A\cup B\subseteq E$, then $A\cap E$ and $B\cap E$ form a disconnection of $E$, so $E$ is disconnected. Conversely, suppose that $A’$ and $B’$ are open sets such that $A’\cup B’\subseteq E$ and $A’\cap E\ne\emptyset$, $B’\cap E\ne\emptyset$, $A’\cap B’\cap E=\emptyset$ (by definition of disconnected). Then setting

$$A=\{x:d(x,A’\cap E)<d(x,B’\cap E)\}$$
$$B=\{x:d(x,A’\cap E)>d(x,B’\cap E)\}$$

we have that $A$ and $B$ are open sets (since $d(x,A’\cap E)-d(x,B’\cap E)$ is a continuous function), disjoint, and for any $x\in A’\cap E$, letting $r$ be such that $B(r,x)\subseteq A’$, we have $d(x,A’\cap E)=0$ (of course) and $d(x,B’\cap E)\ge r$ (since $A’\cap B’\cap E=\emptyset$), so $A\ne\emptyset$, and similarly $B\ne\emptyset$.