The short answer: on a gentle slope, let the fence follow the ground (racked or contour style). On a steeper one, build it in level steps and close the gaps that open underneath. Keep every post plumb, lay out the line with stakes and a string before you dig, and check your local rules first, because height is usually measured from the ground under the fence. If a dog or a small child is the reason for the fence, the gaps matter more than the look.
This guide walks through the layout, the choice between stepped and racked, post depth, gap control, rules, and what to do on a boundary where a physical fence is hard to build.
TL;DR
- Racked (contour) fences follow the slope and suit gentler grades. Stepped fences drop in level stages and suit steeper ones. Angi puts the rough dividing line at about 15 degrees.
- Posts stay plumb on any slope. Downhill posts stand taller out of the ground, and holes need extra depth for gravel.
- Stepping leaves triangular gaps at the bottom. Fill them with blocks, stone or soil over packed gravel, and keep drainage open.
- Height is often measured from the grade directly under the fence, and permits may apply, so check with your city or county before ordering materials.
- Where the slope, rock or an odd boundary makes a fence impractical, a wireless GPS boundary with no buried wire is an option we cover below.
Table of Contents
- Stepped vs. racked: how a fence runs down a slope
- Lay out the line before you dig
- Setting posts on sloping ground
- Closing the gaps so dogs and kids stay in
- When the slope needs grading or a retaining wall
- Rules to check before you build
- When a fence line is hard: a wireless boundary on the slope
- Our perspective on slopes and dog containment
- A boundary with no posts to set
- FAQ
- Sources
Stepped vs. racked: how a fence runs down a slope
There are two basic ways to run a fence down a grade, and the choice drives cost, looks and security.
Racked (also called raked or contour). The rails follow the slope of the lawn while the posts and pickets stay vertical. Angi describes this approach as generally suited to slopes below about 15 degrees. The result is a fence whose top line mirrors the ground, with a consistent, small distance between the bottom rail and the soil.
Stepped. The fence is built in level sections, like stairs. Each panel is flat, and the top drops at each post. Angi says stepped fencing generally suits slopes above 15 degrees. The Home Depot’s slope guide makes the same basic split: a contour fence on a slight incline, a stepped fence on steeper ground.
Here is how they compare on what matters to most owners:
| Factor | Racked / contour | Stepped |
|---|---|---|
| Best slope | Gentle, roughly under 15 degrees | Steeper, roughly over 15 degrees |
| Look | Smooth line that follows the ground | Staircase top line |
| Gaps at the bottom | Small and even when built well | Triangular gaps under each panel |
| Containment of dogs and kids | Better, with fewer openings | Needs gap filling |
| Material limits | Many metal and vinyl systems rack only within a set range | Works with standard flat panels |
That last row is worth checking before you buy. Some prefabricated systems can only rack within a product-specific range, and steeper grades may call for custom construction or stepped panels. Read the manufacturer’s installation sheet for the maximum angle before you commit.
If you want to compare panel styles against specific slope angles, this breakdown of matching fence panels to 12 to 15 degree grades covers the options by slope.
How to estimate your slope
Measure rise over run. Drive a stake at the top and another at the bottom of the run, stretch a level string between them, and measure the vertical drop from the string to the ground at the lower stake. Divide the drop by the horizontal distance. A 3-foot drop over 20 feet is a 15 percent grade, which is only about 8.5 degrees. Percent grade and degrees are different units, so convert before you compare your yard to a manufacturer’s limit.

Lay out the line before you dig
A slope punishes guesswork. A few hours of layout saves you from posts in the wrong place.
- Find the property line. Walk it, and stake it. Use a survey or your plat if you are not sure where it runs.
- Set stakes at the top and bottom of each run, then stretch a level mason’s line between them.
- Mark equal post spacing along the line, and use a plumb line to transfer each mark to the ground.
- Stake gate locations now, not later. Today’s Homeowner recommends staking gates before construction and thinking carefully about where the fence meets existing structures.
- Leave posts tall. The Home Depot’s installation guide suggests leaving posts long during layout and cutting them to final height afterward, rather than trying to predict every post top on a slope.
Slopes often make post spacing tighter. A sloping installation may reduce horizontal spacing between posts, and on extreme slopes may need miter-cut rails or individually cut pickets.
Setting posts on sloping ground
The rule that never changes: every post stays plumb, vertical in both directions, even when the ground tilts.
- Depth. Lowe’s installation guide gives a general rule of burying about one-third of the post, with end, corner and gate posts at least 6 inches deeper. It calls for holes 10 to 12 inches wide with 6 inches of gravel at the bottom.
- Downhill posts. They have to stand farther out of the ground to keep the fence height consistent. Today’s Homeowner recommends 6 to 12 inches of extra hole depth for gravel support.
- Check plumb on two adjacent sides, brace the post with crosspieces, tamp the concrete to remove air pockets, and slope the top of the concrete away from the post. The Lowe’s guide says concrete should cure for 24 to 48 hours before you load the fence.
- Rails. Install them level side to side and following the slope front to back, then cut pickets one at a time.
Before you dig, look at the soil and water. Sandy soil may need wider or deeper footings. Clay can soften when wet or heave. Runoff that pools around a footing will undermine it over time. If water crosses your fence line on a hill, plan where it will go before you pour concrete.
Closing the gaps so dogs and kids stay in
This is the part most fence guides treat as cosmetic. If you have a dog that digs, squeezes or wriggles, it is the whole point.
A stepped fence leaves a wedge-shaped opening under each panel on the downhill side. A racked fence leaves a smaller, more even gap, but a bottom rail that sits too high still leaves room.
Fixes that work:
- Fill under stepped panels. Today’s Homeowner suggests retaining-wall blocks, bricks or decorative stone over packed gravel, while keeping drainage in place so you do not cause erosion.
- Fill with soil. A stepped installation may involve backfilling the gap below the fence, which pairs with taller downhill posts.
- Set the bottom rail low on contour fences. The Home Depot’s guide says bottom rails should sit 3 to 4 inches above the ground.
- Leave water an outlet. Angi advises leaving space under the bottom pickets for water flow. For a dog-safe fence, do that with a buried or anchored barrier, such as stone or block, that lets water pass but not a body.
- Consider preconstructed slope panels, which Angi lists as an option for following the grade.
The tension is real: a tight bottom edge keeps pets in, while an open bottom drains. Solve it with materials that do both, such as gravel-backed stone, rather than choosing one.
If your dog already tests the line
A slope makes every weakness worse, because dogs dig at the high side and jump from the high side. These guides cover each habit: stopping a dog from digging under the fence, stopping a dog from jumping the fence, and a quick audit to make your yard escape-proof.
Some dogs also get frantic at the fence line, barking and lunging at what passes on the other side. That behavior is its own problem and does not go away with a taller fence. A stepwise plan for barrier frustration in dogs shows how trainers approach it.
When the slope needs grading or a retaining wall
Some ground is too steep or too uneven to fence cleanly. Today’s Homeowner says very steep slopes, around 45 degrees, may need terraces or retaining walls to create flatter areas. A fence placed on or near a retaining wall brings extra rules, since walls over a certain height often need engineering, plans and inspections.

A practical test: if you cannot stand upright and set a level across a panel width without a big shim, a plain fence line is not going to behave. Either regrade a strip along the line, build a wall and fence on top, or choose a boundary that does not depend on the ground being cooperative.
Rules to check before you build
Boundary fences sit at the intersection of property law and local code, and slopes complicate both.
- Utilities and lines. Lowe’s recommends checking local ordinances, having underground utilities marked, talking with neighbors and locating property boundaries before you start.
- Everything inside your line. Portland’s residential guide says all fence parts and footings must stay inside property lines. It measures height from the grade immediately under the fence, and for a fence on a retaining wall, from the higher side.
- Height limits vary by place and zone. Portland says fences up to 8 feet may be allowed in many side and rear setbacks, with a 3½-foot limit possible in front setbacks. Under Dallas’s city code, residential front-yard fences have a 4-foot limit and measurement is from the greater of the inside or outside grade in required front yards.
- Permits. Milpitas, California requires permits for swimming-pool fences, fences over 7 feet, and retaining walls over 4 feet or supporting added load. It also requires a foundation inspection before concrete goes in and a final inspection afterward. Mason County, Washington says fences of 7 feet or under may be exempt, but shoreline properties must contact the planning department regardless of height, and fences on irregular grade must follow the grade.
These are examples, not your rules. Your city or county building department and any homeowners association have the final word, so call them before you buy lumber.
When a fence line is hard: a wireless boundary on the slope
Fences work, but some boundaries are awkward: a hillside that needs a retaining wall, rocky ground that fights every post hole, a large rural lot, a long property line, or an HOA that limits fence height. For those, many owners look at a boundary that lives in software instead of in the ground.
A wireless GPS fence stores the boundary on the collar, with no buried wire and no posts. Our guides on setting up a sloped yard wireless fence, choosing a GPS collar for hilly yards and GPS dog fence setup walk through how to map the boundary and train a dog to respect it. If you want to keep a dog out of one part of the yard, such as the steep bank, see our piece on keep-out zones for dogs. For a broader plan, there is a 14-day boundary plan.
Many owners use both: the physical fence where it is easy to build, and a virtual boundary where the terrain gets difficult. Training comes first either way, so the dog learns what the tone, vibration and boundary mean.
Our perspective on slopes and dog containment
We hear the same story from owners of hilly property. The fence goes in along the flat part without trouble. Then the line reaches the slope, the quotes climb, and the question becomes whether to spend money on grading, a wall and custom panels, or to leave a section open and hope.
Our view is that a boundary should follow your needs, not the shape of the ground. That is why we built the HAVEN Freedom collar around boundaries stored on the collar itself: no buried wires, nothing to dig, and a collar you can take with you when you travel. The fence function works without a monthly subscription. A plan is only needed if you want live tracking and escape alerts.
For owners of dogs that dig, jump or wander, we pair the boundary with a training mode that offers an adjustable tone, vibration and optional static correction, and a finder that uses sound, light and Bluetooth radar if a dog does get out. We think a dog is safest when the physical fence, the virtual boundary and the training all point the same way.
Haven
A boundary with no posts to set
The HAVEN Freedom Wireless GPS Dog Fence and Tracking Collar is $349, one time. It creates customizable boundaries without buried wire, includes live 4G tracking and escape alerts through an optional plan, and comes with direct support for setup and troubleshooting. It suits yards where a fence is hard to build, large rural lots, and travel.
See the HAVEN Freedom GPS dog fence collar for details and current availability.
FAQ
Is it better to step or rack a fence on a slope?
Rack it on gentle slopes, roughly under 15 degrees, because the fence follows the ground and leaves smaller gaps. Step it on steeper ground, where flat panels are easier to use. If dogs or small children are the concern, a racked fence usually needs less gap filling.
How do I stop a dog from slipping under a fence on a slope?
Close the downhill gaps with blocks, bricks or stone over packed gravel, and keep the bottom rail low on a contour fence. Keep drainage open so you do not cause erosion. If your dog digs, a buried barrier along the line adds protection.
Do fence posts need to be different on a slope?
They need to be plumb, same as on flat ground, but downhill posts usually stand taller out of the ground and holes need extra depth for gravel. Tighter post spacing is common on slopes. Follow the manufacturer’s sheet for your panel type.
Do I need a permit for a fence on a slope?
It depends on your city or county, the height, and whether a retaining wall or pool is involved. Several jurisdictions require permits for tall fences and for retaining walls above a set height. Call your local building department before you start.
Sources
- How to Build a Fence on a Slope, The Home Depot
- Installation Guide, The Home Depot
- How to Build a Fence on a Slope: Raked and Stepped Methods, Angi
- How to Build a Fence on a Slope, Today’s Homeowner
- Fence Installation Instructions, Lowe’s
- Fences, Decks and Outdoor Residential Projects, City of Portland
- Sec. 51A-4.602 Fence, Screening and Visual Obstruction, Dallas City Code
- Fence or Retaining Wall (Residential), City of Milpitas
- Fence Handout, Mason County, Washington
- Fence on a slope: matching panels to 12 to 15 degree grades
- Barrier frustration in dogs: a stepwise plan
Recommended
Keep reading
en
Rural Mailbox Boundaries for Dogs: Keep Your Dog Back
Keep your dog away from the roadside mailbox and the carrier: what USPS expects, how to set a wireless boundary back from the road,...
Read the postdog won't respond to beep
Dog Won't Respond to the Beep? Why and How to Fix It
A dog that ignores the beep usually hasn't learned what it means. Rule out hearing and pain, then follow a reward-first plan that makes...
Read the postYour adventure starts here
Ready to give your dog more room to roam?
Give your dog more freedom to explore — and give yourself the reassurance of knowing they're never far away.
