This fence calculator works out posts, rails, pickets and the concrete each hole takes. Post depth is the figure that matters most and it is set by your local frost line, not by a rule of thumb, so it asks rather than assuming.
Below the frost line, and that is a local figure rather than a general one. It runs from about 12 inches in the southern United States to 60 inches or more in the northern states, and your building department publishes it.
This is the one part of fence building that is a genuine code input. Everything else on this page is trade practice.
If a post does not reach below the frost line, water in the soil freezes, expands and lifts the post. Over a few winters the fence goes visibly out of line and cannot be pushed back, because the hole below has filled in.
Code Frost depth is set locally by your building department. Convention The common rules of thumb, a third of the post height in the ground and a hole three times the post width, are trade practice with no published standard behind them.
The volume of the hole less the volume of the post. A 4 by 4 post in a 10 inch hole 30 inches deep needs about 1.1 cubic feet, which is roughly two 80 pound bags.
A useful habit: put four to six inches of gravel in the bottom of the hole before the post. It lets water drain away from the end grain rather than sitting against it, and a post that stays wet at the bottom rots there first.
Yes, and this is where fences fail. Corner and gate posts carry loads that line posts do not: a corner post is pulled in two directions at once, and a gate post carries a swinging weight that works it loose over time.
Set them deeper and in a wider hole than the line posts, and use a heavier section where you can. A gate that drops after a year is almost always a gate post that was set like a line post.