It is located about 20 km (12 mi) southwest of Barcelona, just to the north of the massís del Garraf and is the last town on the coast before the comarca of Garraf. The town is famous for its long beach (more than 5 km), for being the place of residence of many famous sportsmen and for being the city which inspired the creation of the character "El Neng de Castefa" who used to appear on the late night show called "BFN" hosted by the showman and presenter Andreu Buenafuente. During the summer, many people from Barcelona and the countryside visit it. Nearby towns include Gavà, Viladecans, Sant Boi de Llobregat, Sitges and el Prat de Llobregat. Castelldefels borders the coast of the Mediterranean Sea between Sitges and Gavà.
On 23 June 2010, 12 young people were killed, and 14 injured, when they were hit by an express train as they crossed the tracks in the railway station at Platja de Castelldefels, while on their way to a summer solstice bonfire party.