It is immediate that a retract of a Hausdorff space must be closed.
The condition that be a retract of
is quite a strong condition. For example if
is compact and
connected then so must
. Thus
cannot be a retract of
.
The boundary
of
is not a retract of
but this is highly non-trivial.