When the war for Mexican independence ended in 1821, the area of Texas was

A) part of Spain.
B) part of Mexico.
C) an independent country.
D) a territory of the United States.