Shulchan Aruch Chapter 549: The Obligation to Fast on the 4 Fasts (2 Paragraphs)
1. One is required to fast on the ninth of Av (תשׁעה באב), the 17th of Tamuz (י׳ז בתמוז), the 3rd of Tishrai (ג׳ בתשׁרי) and the Tenth of Tevet (עשׂרה בטבת) because of the terrible events that occured on these days.
2. Even though it is written “in the fourth month on the ninth day the city was breached”, we do not fast on the 9th but rather on the 17th of Tamuz due to the following reason: Although the city (Jerusalem) was originally breached on the 9th of Tamuz, the second temple was penetrated on the 17th of Tamuz. Therefore, it was enacted to fast on the 17th since the destruction of the second Temple is important to us.
Chapter 550: The Difference Between the Ninth of Av to the Other Fasts (4 Paragraphs)
1. Everyone is obligated to fast on these 4 fasts and it is forbidden to break the restriction. [However if a girl is pregnant or nursing, that entails a lot of anguish/pain, she does not fast. Even if she experiences no discomfort, she is not obligated to fast unless a custom exists to be stringent. And this is only in relation to the 3 fasts. But the fast on the 9th of Av, she must observe it to completion (if she experiences no discomfort).]
2. On these fasts, with the exception of the Ninth of Av, it is permitted to wash, anoint, have intercourse, and it is not necessary to restrict these things the day.
3. If any of these 4 fasts fall out on the Sabbath, they are postponed until after the Sabbath. [And if they fall out on Friday, read ויחל by Shacharit and Mincha. If there is a wedding on a Friday fast, the custom is to recite by Mincha ויחל and afterwards to do the wedding.]
4. On the Sabbath before the fast, the Chazon announces the upcoming fast with the exception of the 9th of Av, Yom Kipor, and the fast of Esther, since we rely on the word of mouth. [The Askenazic custom is to not announce any of these.]
 The Mishna Brura says that surely the same applies if one is ill without physical danger (experiencing a lot of pain). In this case, you are not required to fast and it is forbidden to be stringent on yourself.