Languages
[Edit]
EN

CSS - style radio button (HTML element)

3 points
Created by:
Marley-Marks
712

In this article, we would like to show you how to style radio button using CSS.

Radio button styled using CSS.
Radio button styled using CSS.

Practical example

Edit

In this example, we use :checked pseudo class to switch between .default and .checked style changing SVG icon when the radio button is clicked.

In the below source code, you can configure own colors by changing:

  • #5f6368 - label font color
  • #767676 - icon border color   (unchecked state)
  • #ffffff - icon filling color     (unchecked state)
                       icon ring color        (checked state)
  • #0075ff - icon circle color      (checked state)

Source code:

 

Multiple radio buttons

Edit

In this example, we create two radio buttons that are assigned to the same group by common name.

 

Multiple radio buttons (with SVG components)

Edit

In this example, we use SVG components to avoid icons source code duplications.

 

See also

Edit
  1. HTML - radio input

  2. HTML - select radio input on click on related text

  3. CSS - style input checkbox (HTML element)

  4. SVG - create reusable component in pure HTML

References

Edit
  1. :checked - CSS: Cascading Style Sheets | MDN
  2. <input type="radio"> - HTML: HyperText Markup Language | MDN

Alternative titles

  1. CSS - style radio buttons onclick
  2. CSS - style radio input on click event
  3. CSS - style radio inputs onclick
  4. CSS - style input radio HTML element
1
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.
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.

❤️💻 🙂

Join