What Are HTML Radio Buttons?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 25 October 2019
  • Copyright Protected:
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
People can experience an altered state of consciousness by staring into someone else's eyes for 10 minutes.  more...

November 17 ,  1973 :  US President Richard Nixon insisted he was not a crook.  more...

In a HyperText Markup Language (HTML) document, radio buttons are a type of visual element that can be selected by a user. HTML radio buttons are unique, because they offer the user several options but only allow one of the given options to be selected at any one time. One of the most common uses for HTML radio buttons is to capture a choice within user input forms, although they also can have their selection and de-selection events intercepted by scripts or other programs, allowing them to act as instant selectors for other elements on a web page. Through the use of cascading style sheets (CSS) and JavaScript®, HTML radio buttons can use custom images for display, overriding their default appearance. Examples of situations in which HTML radio buttons could be used include selecting a gender, which can only have one value from two different options, or choosing a single shipping address when multiple addresses are listed.


In some aspects, HTML radio buttons are similar to HTML checkboxes. Each button is assigned an image or text label that is displayed where the button is located within a layout. Next to this label is a circle that is empty when the radio button is not selected and has a dot or other fill pattern inside it when it is selected. A user can click on the circle to select it; the unique aspect of HTML radio buttons is that, when a button is selected, all other buttons in the same group are de-selected, allowing only one item to be chosen at a time. This is unlike checkboxes, which are similar but allow any number of options to be selected at once.

There are two values within the properties of HTML radio buttons that are important to their use. The first is the name field that identifies the group to which a radio button belongs within an HTML document, and the second is the value field. When a button is selected, all other radio buttons with the same name, also called their group, are deselected. Using different group names allows different sets of radio buttons to exist within the same document. The value tag is the actual return value for the radio button when it is selected and submitted to a script or program for processing.

The visual display of HTML radio buttons can be modified in a few ways. Through the use of standard HTML and CSS alignment values, the buttons can be dynamically arranged within a document in much the same way that an image is aligned. The appearance of the buttons, specifically the circle and selected circle images, can be customized completely and replaced with user-generated images by manipulating the document object model (DOM) with CSS and JavaScript®, although browser support is not always consistent from one application to another.


You might also Like


Discuss this Article

Post your comments

Post Anonymously


forgot password?