The name attribute in a radio button serves to group related radio buttons together. When radio buttons share the same name attribute, only one option can be selected within that group. This ensures that the user can make a single choice from the available options.