Railings are required in raised areas and stairways, and, in Maine, their height is regulated by the Maine building code. Interior railings are called "handrails," and are generally required in Maine on any stairway that includes more than three steps. Exterior railings are called "guardrails," and, in Maine, are required on any balcony, porch, floor area (such as a deck) or stairs raised more than 30 inches from the ground.

...
A railing’s height should be measured from the depth of the finished pathway or floor.

Residential Handrails

In a two- or single-family house, handrails should be 30 to 38 inches high. If the handrail is also the guardrail for an outdoor section of the house (if it leads from the interior of the house onto a porch, for example), it must be 34 to 38 inches high. In order to measure the height of a railing in a residence, the bottom of the railing's height is considered to be where the treads or the finished floor is

Non-Residential or Multi-Family Dwelling Handrails

In all other buildings (except two- and single-family houses) stairways with three or more steps must have handrails on either side of the steps. The railing must be at least 34 inches high, have a diameter of 1-1/4 to 2 inches, must be 1-1/2 inches or further from the adjacent wall and must be within 30 inches of the rest of the step. If it isn't round, the handrail should be 4 to 6-1/4 inches wide.

Guardrails

On residential porches, balconies, decks and stairs the guardrail must be at least 36 inches in height. There should be 34 inches or fewer of open space between the guardrail and the finished floor or the stair tread. On non-residential or multi-family dwellings, the guardrails must be 42 inches or more in height when measured from the walking surface or the edge of the stair tread.

Baluster Spacing

In order to close off the open space between the guardrail and the floor or step, there must be balusters spaced tightly enough together that a sphere 4 inches in diameter can't fit between them. If the baluster at the end of the stairs is out of line with the rest of the balusters (for example, if the guardrail turns at the end), the opening between that baluster and the others should still be small enough that a 6-inch sphere wouldn't fit between the openings.