VOOZH about

URL: https://www.geeksforgeeks.org/css/css-checked-selector/

⇱ CSS :checked Selector - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CSS :checked Selector

Last Updated : 29 Aug, 2024

The checked selector is used to select all checked elements in the input tag and radio buttons. This selector is used with radio buttons, checkbox and option elements. 

Syntax:

:checked {
// CSS property
}

Example 1: In this example, The CSS :checked selector targets checked input elements. It sets a height and width for checked checkboxes and applies a green color to the h1 element.

Output:👁 Image

Example 2: In this example, The CSS option:checked selector targets the selected option within a <select> element. It sets a height of 10px and a font size of 20px for the selected option.

Output:👁 Image
Supported Browsers: The browser supported by :checked Selector are listed below:

  • Apple Safari 3.1 and above
  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Firefox 1.0 and above
  • Opera 9.0 and above
Comment
Article Tags: