HTML - radio input

0 points
Created by:

In this article, we would like to show you how to create and use radio input elementin HTML.

Quick solution:

// ONLINE-RUNNER:browser;

  <input type="radio" name="group-name" value="value-1" checked />
  <span>Value 1</span>

<!-- or using id-for attributes relation: -->

<input type="radio" name="group-name" value="value-2" id="two" />
<label for="two" >Value 2</label>


With the name attribute we can assign radio input elements to the groups. Only one radio button at the time can be selected in each group.


Practical example

In this example, we create radio input using the input element's type="radio" attribute.

// ONLINE-RUNNER:browser;

<!doctype html>
  <div>Select color:</div>
    <input type="radio" name="color" value="red" checked />
    <input type="radio" name="color" value="blue" />


Alternative titles

  1. HTML - input type radio
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

HTML - input element types

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂