Saturday, 6 August 2022

21 - How to Create and Style Radio Button in HTML

What is Radio Button Element in HTML 

Radio buttons let a user select ONLY ONE of a limited number of choices. It is defined as <input type="radio"> and has three main attributes - name, value, and checked. The name is sent along with the selected value to the server.  The value attribute is the value passed to a script or a CGI program to indicate which button is selected. Be sure you assign a different value to each button. The checked attribute sets a default value when the page loads into the browser and is used with only one radio button in a group.

The entire group of radio buttons shares a single name and a single object. To access the individual buttons, you treat the radio object as an array. The buttons are indexed, starting with 0. You use the checked property of a radio button to check its current state. The following statement checks the first radio button in the ctype group on the contact form:

document.contact.ctype[0].checked == true;





 

Learn the HTML5 language in this tutorial series. These tutorials are designed for new programmers to provide them thorough knowledge of full stack web development.

Watch Full Playlist Here

Watch Complete One Video Here

AI Meets SEO: The Smartest Way to Improve Your Google Rankings in 2025

  Search engine optimization (SEO) is no longer just about stuffing keywords and building backlinks—it's about strategy, relevance, and ...