Apartheid was a time in the history of South Africa. What is meant is that the state separated the races during this time. The ruling whites had many more advantages and rights than the other people in the country. The word apartheid comes from the South African language Afrikaans. It means something like "being different". Because South Africa ruled Namibia for a long time, apartheid existed there too.
Apartheid began after 1900 and was at its worst between 1940 and 1980. In 1994, the government changed and Nelson Mandela came to head the state. This marked the end of apartheid.
Even before apartheid, whites in South Africa treated non-whites worse. People with dark skin or those from Asia were considered non-white. In 1948, a certain party won the elections in South Africa: the National Party. It took over the government and introduced racial segregation and discrimination against non-whites everywhere.
There were people in South Africa who resisted apartheid. One example was Nelson Mandela. But people in other countries did not like apartheid at all. In Britain and Germany, for example, demonstrations called on people not to buy fruit from South Africa.
The government of the National Party in South Africa finally gave up. It understood that apartheid was damaging the country. In 1989, Frederik Willem de Klerk became the new head of government. Step by step, apartheid was abolished. In 1994, Nelson Mandela became the new head of state of South Africa.