Why does the empty set have a cardinality of zero? Consider the following sets:
$$ A = \{1, 2, \{1,2\}, \emptyset \} $$
$$ B = \emptyset $$
My book says that $|A| = 4$ and $|B| = 0$. Why is $\emptyset$ considered an element if it's a subset, but not when it's on its own?
 A: Sets can be elements of other sets. They can also be subsets. That is irrelevant for defining cardinality of a set.
The cardinality of a set is "the number of elements in a set". $\varnothing$ has no elements. It has zero elements. So its cardinality $0$. Much like that $\{1,2\}$ has cardinality $2$, regardless to the fact it is an element of $A$.
A: The "philosophical" issue behind this which in the beginning confuses many people is that in everyday mathematics you're almost always dealing with "typed" sets - meaning that the elements of the sets you'll encounter are always of the same kind: You might have sets of natural numbers like $\{1,2,3\}$ or sets of reals like the interval $[0,\pi)$.  Later you'll maybe encounter sets of vectors or sets of functions and so on.  Still, the "roles" are always kind of clear, sets are "containers" for "other" objects - the ones you are "really" dealing with.  [Things get muddy once you start with topology, though.]
But in (axiomatic) set theory there are no "other" objects.  Everything you'll ever encounter are sets - which entails that all sets have to be able to play both roles, the "container role" as well as the "element role".
So, your $A$ above is a set which is a container for four other things - and these four other things are also sets and one of them is $\emptyset$.  (In other words, $\emptyset$ here plays the "role" of an element of a set.)  But for the cardinality of $A$ the only thing that "counts" is how many objects it contains, so it is $4$.  It doesn't matter whether one of its elements - $\emptyset$ - has cardinality $0$ or whether another element - $\{1,2\}$ - has cardinality $2$.  Each element of a set has the same "right" to be counted - no matter whether it's the tiny empty set or a huge uncountable bouncer like $\mathbb R$.
But $\emptyset$ can also be viewed in its "role" as a set containing objects.  And as a set it is a container for zero elements (by definition).  So its cardinality is $0$.
[In case you're wondering: Yes, $1$ and $2$ are also sets as far as set theory is concerned.  More about this can e.g. be found in other answers on this site, e.g. here.]
