Catalonia had some independence before the 20th century which was when the Spanish civil war happened.
Because of the victory of the said war, dictator Franco Bahamonde ruled over Spain which took away the independence Catalonia had. Fortunately, in 1975 when Franco Bahamonde died, Catalonia regained some of their freedom. In 2015, separatists won the regional election which made the leaders who wanted independence to go to court and ask for a referendum, but it was declared illegal.
In the Catalonian Parliament 37% participated in the vote where 90% of them voted for the separatists. However, the Ciudadanos party got the majority of the votes and their wish was for Catalonia to continue being a part of Spain.