Radio buttons are a fundamental part of HTML form inputs, allowing users to select one option from a given set. They are indistinguishable from each other, making them perfect for creating lists of options where only one can be chosen. Let's explore radio buttons with examples and understand how to use them effectively in your HTML forms.

Radio buttons are defined using the tag with type="radio". Each button must have a unique name attribute for the group. Here's a basic example:

Creating Radio Buttons
To create radio buttons, you'll use the following syntax:

```html Label ```
The name attribute is crucial as it groups the radio buttons together, allowing only one to be selected at a time. The value attribute represents the selected option's value if it is checked. Here's an example of creating three radio buttons:
```html Apple Banana Cherry ```
Pre-selected Options

You can pre-select an option by adding the checked attribute to the respective input tag. This is useful for setting a default option or implementing a multi-step form with pre-filled values.
```html Apple ```
Labeling Radio Buttons
Labeling radio buttons makes them more accessible and improves user experience. Wrap the entire input element in a

```html ```
Screen readers can now read out the label associated with the radio button, and clicking the label itself will select the corresponding radio button.
Radio Button Layout
Arranging radio buttons neatly can enhance the user interface. You can use CSS to style and layout your radio buttons.

Using CSS for Styling
With CSS, you can change the appearance of radio buttons, add custom checked styles, and align them better. Here's an example using :checked pseudo-class to change the background color of the radio button when it's selected:


![Custom Radio Button [ 25+ Input Radio Button New Examples ]](https://i.pinimg.com/originals/10/49/2e/10492eba36dd2e54f704e2f19b838ba9.png)

















```css input[type="radio"] { background-color: #fff; border: 1px solid #ccc; width: 20px; height: 20px; } input[type="radio"]:checked { background-color: #4CAF50; } ```
Aligning Radio Buttons
To align radio buttons for better readability, consider using flexbox or CSS grid layout. Here's an example of using flexbox to center the labels and radio buttons:
```css .flex-container { display: flex; align-items: center; } .flex-container label { margin-right: 10px; } ```
With these techniques, you can create visually appealing and user-friendly radio buttons in your HTML forms. Now that you've learned how to create and style radio buttons, it's time to apply this knowledge to your projects and enhance your users' experience.