Spain colonized Costa Rica in the 16th century. But the country gained independence in 1821 and has been a sovereign nation ever since.