Yogesh Chauhan's Blog

How to change the style for checked radio button or checkboxes using CSS?

in CSS on March 9, 2021

CSS selectors are pretty handy sometimes when we want to style elements based on user interaction.

To change the style for checked radio button or checkboxes we can use CSS :checked Selector.

The :checked selector matches checked input elements for checkboxes and radio buttons and and option element.

It’s supported in all major browsers.

:checked selector syntax


:checked {
  style the checked elements
}

Example Solution


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Killing A Project Part 3: How can an organization ensure that a doomed project is killed as early as possible?Miscellaneousaddcslashes() and addslashes() String Functions in PHPPHPMySQL queries to get data rows from previous month as well as from last 30 daysSQL/MySQLIN Operator in PostgreSQLPostgresHow to get previous days or next days in PHP?PHPHow to position an image on top of another image using CSS?CSSHow to Pop an Alert Box in PHP?JavaScriptCreate dynamic selectors using SCSS (Sass)SCSSHow to display random posts in WordPress?WordPressHow to load a module with configuration in SCSS?SCSSThe :last-of-type selectorCSSHow to render Lists in React?React