Guardrails are composed of an assembly of parts. There are different methods for building guardrails with a variety of materials for decks, but most rails built from wood share a common set of components.
Usually, 4x4 wood posts are attached to the deck frame to provide the support for the rail. Some composite systems require you to install a wood post that will be covered by a hollow sleeve. The 4x4s must be long enough to project the railing at least 36” above the frame and must extend below the deck surface for attachment to the frame as a means of support.
Most rail systems use horizontal members running between the posts as top and bottom rails to create the frame for the infill. With wood decks, 2x4s are often used for this purpose.
The top rail must be set so the top of the guardrail is at least 36” above the floor. Likewise, the bottom rail is usually raised above the surface to allow a sweep space for snow and leaves, but it may not extend beyond 4” from the floor.
A top cap may or may not be used. 2x6 boards laid flat work well and provide a level surface to place drinks. You can use a router with a roundover bit to create a nice edge detail.
The infill section of rails is usually constructed of the repeated use of pickets or balusters. These can come in a number of materials, shapes and sizes.