How to understand both closed and open set in topology? We've defined the connectedness in topology in class in this way that a topological space is connected if the only both open and closed set is empty set or the whole set. 
Now I got the explanation from Wikipedia:"Now consider the space $X$ which consists of the union of the two open intervals $(0,1)$ and $(2,3)$ of $\mathbb{R}$. The topology on $X$ is inherited as the subspace topology from the ordinary topology on the real line $\mathbb{R}$. In $X$, the set $(0,1)$ is clopen, as is the set $(2,3)$. This is a quite typical example: whenever a space is made up of a finite number of disjoint connected components in this way, the components will be clopen."
I understand the last line of the explanation, because it corresponds to our definition of connectedness. But Can anyone tell me why $(0,1)\bigcup(2,3)$ are both open and closed(by definition)?I understand it's open but why it's closed?
A set is said to be open if there always exists a neighborhood of each point in this set and the neighborhood also is contained in the set. 
A set is said to be closed if its complement is open.
Thanks for helping me :)
 A: Every space is both open and closed in itself. Of course, $X:=(0,1)\cup(2,3)$ is open and not closed in the real line.
Now, it's clear that both $(0,1)$ and $(2,3)$ are open in the real line, so open in $X$ in the subspace topology. Since $(0,1)=X\setminus(2,3)$, then $(0,1)$ is closed in $X$. Likewise, $(2,3)$ is closed in $X$.
A: Your topological space under consideration is $(0,1)\cup (2,3)$, therefore $(0,1)\cup (2,3)$ must be open as it is the whole set. Since complement of $(0,1)\cup (2,3)$ (relative to the space being considered) is the empty set, which is open, then $(0,1)\cup (2,3)$ is by definition closed. Basically the whole space $X$ is always both open and closed. 
A: The thing you may not be understanding is that whether a set is closed or open depends highly on what metric or topological space it lives inside.
Wikipedia is talking about the space $(0,1) \cup (2,3)$.
$(0,1)$ is closed because it's complement is $(2,3)$ -- obviously an open set.
EDIT: it is unclear in your question whether "$(0,1) \cup (2,3)$ are both open and closed" means "$(0,1)$ and $(2,3)$ are both open and closed" or "$(0,1) \cup (2,3)$ is both open and closed".
