Texas occupies the south-central segment of United States and is the 2nd largest state by area after Alaska. The territory of Texas was part of the Spanish Empire for more than a century. It was then part of the new country of Mexico from 1821 to 1836, when it gained its independence, and had a short-lived existence as a republic before joining the Union in 1845.