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 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

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
How to load variables, functions, and mixins from another module in SCSS?SCSSKilling A Project Part 1: What criteria should be used to cancel/kill a project?MiscellaneousHow to avoid element shift on border change while hovering in CSS?CSSGlobal JavaScript methods to convert variables to numbersJavaScript@forward rule in SCSS (Sass)SCSSSanitize inputs using built-in WordPress functionsWordPressResponsive Masonry Grid using CSS columns PropertyCSSCommon Table Expressions (CTE) in PostgreSQLPostgresHow to Use the EXISTS and NOT EXISTS Operator with a Subquery in SQL and MySQL?SQL/MySQLsubstring() Method in JavaScriptJavaScriptGeneral concepts in DrupalDrupalHow to find the HCF or GCD and LCM of two given numbers using Swift?Swift