
In this tutorial, we explore a stylish radio button of HTML and CSS that will enhance the user experience of your web forms. Here we are implementing a custom radio button design with coffee-colored backgrounds and bold tick marks, providing a delightful interactive experience for your website visitors.
HTML Code for Radio Buttons
<div class="survey-container">
<h2>Your favorite tech language:</h2>
<ul>
<li>
<input type="radio" id="option1" name="selector">
<label for="option1">Python</label>
</li>
<li>
<input type="radio" id="option2" name="selector">
<label for="option2">JavaScript</label>
</li>
<li>
<input type="radio" id="option3" name="selector">
<label for="option3">Java</label>
</li>
</ul>
</div>
CSS Code for Radio Buttons
body, html {
height: 100%;
background: #222222;
font-family: 'Lato', sans-serif;
}
.survey-container {
display: block;
margin: 40px auto;
width: 500px;
padding: 20px;
}
h2 {
color: #AAAAAA;
}
.survey-container ul {
list-style: none;
padding: 0;
}
ul li {
color: #AAAAAA;
display: flex;
align-items: center;
padding: 20px 0; /* Decrease top and bottom padding */
border-bottom: 1px solid #333;
}
ul li input[type=radio] {
appearance: none;
background-color: #D8D8D8; /* Default background color */
margin-right: 15px; /* Increase margin between button and label */
border: 2px solid #000; /* Black border color */
border-radius: 50%; /* Make button circular */
width: 30px; /* Increase button size */
height: 30px; /* Increase button size */
display: inline-block;
position: relative;
cursor: pointer;
outline: none;
transition: border 0.25s linear, background-color 0.25s linear; /* Add background-color transition */
}
ul li input[type=radio]:checked {
background-color: #6F4E37; /* Coffee color */
border-color: #9ED3A6; /* Change border color on click */
}
ul li input[type=radio]:checked::after {
content: '\2713';
font-size: 18px;
color: #FFFFFF;
font-weight: bold; /* Make tick sign bold */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
ul li label {
cursor: pointer;
transition: color 0.25s linear;
}
ul li:hover label {
color: #FFFFFF;
}
ul li:hover input[type=radio] {
border-color: #FFFFFF;
border-width: 4px; /* Increase border width on hover */
}
Tags:
- Stylish radio buttons tutorial
- Custom radio buttons design
- HTML CSS radio button styling
- Modern radio button examples
- Custom tick mark radio buttons
- User-friendly radio button design
- CSS techniques for radio buttons
- Radio button styling tips
- How to create attractive radio buttons
- Enhancing form UI with radio buttons
- Best practices for radio button design
- Creating visually appealing radio buttons
- Customizing radio buttons with CSS
- Web design tutorial: radio button styling
- Interactive radio buttons with CSS transitions