There is no single distance in Spain: how close to the boundary you can build is decided by each municipality’s planning rules, through the general plan and the zoning ordinance for the area where the plot is located. For detached single-family houses, the usual requirement is a setback of between 3 and 5 metres from each boundary; for terraced, semi-detached or party-wall typologies, building takes place on the boundary itself.
The Spanish Civil Code does not set a general separation distance for building. What it does regulate at national level are windows overlooking the neighbour’s property, planting and rainwater run-off from the roof.
What a setback is and who sets it
A setback (retranqueo) is the strip of land that must be left clear between the building and the plot boundary. Many regulations distinguish between the setback proper, measured from the official building line (the street frontage), and the separation to boundaries, which refers to the side and rear limits. It is usually measured perpendicularly from the façade to the nearest boundary.
Both parameters are set by municipal planning: the general plan (PGOU) or subsidiary regulations and, within them, the ordinance or zoning rule that applies to each plot. In recently developed sectors, the figure appears in the partial plan or the detailed study.
The land classification and the applicable ordinance are the first things worth checking among the types of plot for building a home.
How close to the boundary you can build, by typology
The figures below are indicative. The distance that applies to a specific plot is always the one set in its ordinance.
| Situation | Usual distance to the boundary | Who sets it |
|---|---|---|
| Detached single-family house | Between 3 and 5 m from each boundary | Zoning ordinance of the general plan |
| Semi-detached house | 0 m on the shared boundary | Zoning ordinance |
| Terraced house | 0 m on the side boundaries | Zoning ordinance or partial plan |
| Closed block (between party walls) | 0 m on the sides | Building lines of the general plan |
| Rural land | 5 m or more | Regional law and municipal planning |
| Windows and balconies with direct views | 2 m to the neighbouring property | Civil Code, Article 582 |
For detached houses, some ordinances link the separation to the height of the building, for example half the height of the façade with a minimum of 3 metres.
When you can build right up to the boundary
Building on the boundary is possible when the ordinance provides for it. The three most common cases are:
- Terraced or semi-detached typologies. The ordinance requires or allows one or both side boundaries to be shared. For semi-detached houses, it is usually a requirement that no party walls are left exposed.
- Building between party walls. In town centres and closed blocks, the building occupies the full plot frontage and rests on both side boundaries.
- Attachment agreement. Some detached-housing ordinances allow building against a boundary if the adjoining owner agrees. A notarial document or registration at the Land Registry is usually required.
A private agreement between neighbours does not replace the regulation: if the ordinance does not provide for attachment, the adjoining owner’s consent does not allow the separation to be removed. When building does take place on the boundary, the wall cannot have windows overlooking the adjoining property.
What the Civil Code does set: light openings, views, trees and water
The Civil Code does not prevent you from raising a blind wall next to the boundary, but it places conditions on openings, planting and rainwater drainage in every municipality.
| What it regulates | Article | Distance or condition |
|---|---|---|
| Light openings in a wall adjoining another property | 581 | 30 cm square, next to the ceiling, with an iron grille and wire mesh |
| Windows with direct views, balconies and projections | 582 | 2 m between the wall and the neighbouring property |
| Side or oblique views | 582 | 60 cm |
| How these distances are measured | 583 | Direct views, from the wall or the projection; oblique views, from the dividing line |
| Rainwater from the roof | 586 | Onto your own land or the public highway |
| Trees and planting | 591 | Unless an ordinance or local custom says otherwise, 2 m for tall trees and 50 cm for shrubs or low trees |
The distances for views do not apply to buildings separated by a public road (Article 584). If the neighbour has acquired a right to direct views over the plot, Article 585 prevents building closer than 3 metres.
In territories with their own civil law, such as Catalonia, Aragon or Navarre, light openings and views have specific regulations.
These rules are in addition to the planning rules: a window may comply with the Civil Code’s 2 metres and the façade may still breach the separation set by the ordinance. The height of boundary walls has its own regulations, covered in our articles on the legal height of walls between neighbours and the maximum height of a villa’s boundary wall.
Swimming pools, pergolas, sheds and other outbuildings
Each ordinance decides whether outbuildings count as built development and whether they must respect the same separation as the house.
- Swimming pools. Some municipalities apply the general separation to them, while others set a shorter distance to the pool basin.
- Pergolas and porches. An open pergola is usually treated more flexibly than a covered porch, which normally counts towards site coverage and must keep the separation.
- Sheds, storerooms and garages. Some ordinances allow them to be built against the boundary within limits of floor area and height; others subject them to the same distances as the main building.
Rural land: greater distances
On rural or non-developable land, separations are set by the planning legislation of each autonomous community.
By way of reference, Galicia’s Law 2/2016 on land requires setbacks of no less than 5 metres from the plot boundaries. The Rural Land Regulations of Castilla-La Mancha establish, in the absence of any other provision in the planning, 5 metres to boundaries and 15 metres to the centre line of tracks.
To these distances are added those of sector-specific regulations when the property borders roads, watercourses or drovers’ roads.
How to find out how close to the boundary you can build on a specific plot
The exact figure is obtained from the plot’s planning documentation, in this order:
- Identify the plot on the zoning maps of the general plan, which indicate the applicable ordinance.
- Read the zoning ordinance in the planning regulations: setback from the building line, separation to boundaries, site coverage and cases where attachment is allowed.
- Request a planning certificate or report (cédula urbanística) from the town hall. It sets out in writing the rules that apply to the property.
- Consult the municipal technical services on doubtful cases: corner plots or irregular boundaries.
- Commission a topographic survey, because distances are measured from the actual boundaries.
It is worth carrying out this check before buying the land: on narrow plots, two side separations of 3 metres greatly reduce the buildable width.
What happens if you build closer than permitted
Where a building encroaches on the separation strip, the town hall can open proceedings to restore planning legality, as well as disciplinary proceedings.
If the works cannot be legalised, demolition of the part that breaches the regulation is ordered, at the expense of the party responsible. The period within which the Administration can act is set by each regional law; in the Community of Madrid, Law 9/2001 on land sets it at four years from the full completion of the works.
The neighbour has two routes available. National land law recognises a public right of action to demand compliance with planning rules, so they can report the matter to the town hall. In addition, they can go to the civil courts to request the closure of windows that breach the distances for views or the removal of trees planted closer than the legal distance.
How Cabana approaches the siting of a house on the plot
Cabana is an architecture studio in Madrid that designs and supervises the construction of single-family homes. Before designing, the studio analyses the plot’s ordinance and checks the boundaries against a topographic survey. With that information, it defines the position of the house, the swimming pool and the outbuildings within the required separations.
In summary
How close to the boundary you can build depends on the municipal ordinance for each plot: between 3 and 5 metres is the most common requirement for detached houses, and zero for terraced, semi-detached or party-wall typologies. Building on the boundary is only possible when the ordinance provides for it.
The Civil Code adds limits that apply in every case: 2 metres for windows with direct views, 60 centimetres for oblique views, roof water kept within the plot and minimum distances for planting. A planning certificate and a topographic survey make it possible to fix the position of the house.
Frequently Asked Questions
Can I build right up to the neighbour's party wall?
Only if the zoning ordinance allows terraced, semi-detached or party-wall construction, or provides for attachment with the adjoining owner’s consent. In a detached-housing zone without such a provision, the house must keep the separation to boundaries even if the neighbour agrees.
Is the setback measured from the fence or from the property line?
It is measured from the boundary, that is, from the legal limit of the plot, and not from the fence or wall, which may be offset. That is why it is advisable to have a topographic survey before setting out the works.
Do eaves, balconies and projecting elements count towards the separation to boundaries?
It depends on how the ordinance defines the building line and what projections it allows over the separation strip. For views, the Civil Code measures the 2 metres from the line of the projection where there is one.
Can I open a window in a wall less than 2 metres from the neighbouring property?
Not with direct views. The Civil Code only allows light openings of 30 centimetres square, located next to the ceiling, with a grille and wire mesh, and the neighbour may block them if they build on their own land.
Is an old building that does not respect the separation to boundaries illegal?
If it was built in accordance with the rules in force at the time, or the period within which the Administration can act has expired, it is usually left in a non-conforming or equivalent status. That status limits the works that can be authorised, normally to upkeep and maintenance, depending on the regional law and the plan.


