Comments on: :checked https://css-tricks.com Tips, Tricks, and Techniques on using Cascading Style Sheets. Fri, 07 Jan 2022 12:01:48 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Mukesh Yadav https://css-tricks.com/almanac/selectors/c/checked/#comment-1787980 Fri, 07 Jan 2022 12:01:48 +0000 http://css-tricks.com/?page_id=14166#comment-1787980 In reply to Rex.

You can use parent class.

]]>
By: Rex https://css-tricks.com/almanac/selectors/c/checked/#comment-1667621 Sat, 23 Feb 2019 22:50:20 +0000 http://css-tricks.com/?page_id=14166#comment-1667621 How can I get different styles for different checkboxes’ labels, on same page?
I’ve trying several ideas and nothing works for me.
I always get the same style for all my labels on different checkboxes.
Thanks in advance.

]]>
By: Geoff Graham https://css-tricks.com/almanac/selectors/c/checked/#comment-1653005 Wed, 31 Oct 2018 13:39:53 +0000 http://css-tricks.com/?page_id=14166#comment-1653005 In reply to dennisclaessens.

Hey there! Do you happen to have a link to a Codepen (or some other demo with the code) where that is?

]]>
By: dennisclaessens https://css-tricks.com/almanac/selectors/c/checked/#comment-1653003 Wed, 31 Oct 2018 11:52:49 +0000 http://css-tricks.com/?page_id=14166#comment-1653003 I try this, but it seems I cannot target an alement which is outside the form element where the checkbox is. Is this not possible?

]]>
By: Max https://css-tricks.com/almanac/selectors/c/checked/#comment-1616047 Sun, 11 Feb 2018 16:02:24 +0000 http://css-tricks.com/?page_id=14166#comment-1616047 In reply to Geoff Graham.

I did some cleaning and now it’s working just fine! I don’t remember what was the previous state in order to compare them and learn about it :-\ Thank you for your help.

]]>
By: Geoff Graham https://css-tricks.com/almanac/selectors/c/checked/#comment-1616026 Sat, 10 Feb 2018 20:44:08 +0000 http://css-tricks.com/?page_id=14166#comment-1616026 In reply to Max.

Hm, that’s odd. The CSS should not change the state of the checkbox, but merely style it based on the state of it — in this case, when it is in a checked state. Have you tried removing one each property individually to see if one of them is the culprit? That might help isolate the issue, if it is in the CSS.

]]>
By: Max https://css-tricks.com/almanac/selectors/c/checked/#comment-1616014 Sat, 10 Feb 2018 15:24:24 +0000 http://css-tricks.com/?page_id=14166#comment-1616014 Hi, Can anybody help me? I’m practicing a to-do list website and I added the following attribute to my CSS file. It doesn’t allow me to uncheck any checkbox after it was checked. What should I do?

If I remove this attribute, any checkbox can be checked or unchecked.

input[type=checkbox]:checked + label {
    text-decoration: line-through;
    opacity: 0.4;
}

I’m working on Google Chrome Version 64.0.3282.140 (Official Build) (64-bit).

]]>
By: Joe, UX Designer https://css-tricks.com/almanac/selectors/c/checked/#comment-1604201 Mon, 19 Sep 2016 22:26:54 +0000 http://css-tricks.com/?page_id=14166#comment-1604201 In reply to Joe, UX Designer.

Also interesting: there is a 3rd state for checkboxes, radio button groups and bars. It is :indeterminate and can be set with JavaScript.

]]>
By: Joe, UX Designer https://css-tricks.com/almanac/selectors/c/checked/#comment-1604200 Mon, 19 Sep 2016 22:07:54 +0000 http://css-tricks.com/?page_id=14166#comment-1604200 I’m reading that :checked pseudo selector also works with select options, affecting the option the user selects, not just checkbox and radio buttons. It was news to me but makes sense.

]]>
By: Miah https://css-tricks.com/almanac/selectors/c/checked/#comment-1602579 Thu, 30 Jun 2016 21:30:33 +0000 http://css-tricks.com/?page_id=14166#comment-1602579 Checkbox to alternate Submenu on/off over background. iphone safe?

<input type="checkbox" > Guess what <div> Working Submenu <br>over background</div> ????????????????????????
<style>
input[type=checkbox] + div {display:none}    
input[type=checkbox]:checked + div {display:inline-block;position:absolute;background-color:#ddf} 
</style>
]]>
By: Miah Ekholm https://css-tricks.com/almanac/selectors/c/checked/#comment-1602566 Thu, 30 Jun 2016 08:15:27 +0000 http://css-tricks.com/?page_id=14166#comment-1602566 1st time i write here did not know about how to share code, i do now tho
Lines below is a perfect working Submenu example. Shortest code?
Sorry about previous comment this one is what i want to share.

<input type="checkbox" > Guess what <div> Working Submenu </div>
<style>
input[type=checkbox] + div {display:none}    
input[type=checkbox]:checked + div {display:inline-block} 
</style>
]]>
By: Miah Ekholm https://css-tricks.com/almanac/selectors/c/checked/#comment-1602564 Thu, 30 Jun 2016 08:12:36 +0000 http://css-tricks.com/?page_id=14166#comment-1602564 Lines below is a perfect working Submenu example. Shortest code?
Sorry about previous comment this one is what i want to share.

<input type="checkbox" > Guess what <div> Working Submenu </div>
<style>
input[type=checkbox] + div {display:none}    
input[type=checkbox]:checked + div {display:inline-block} 
</style>
]]>
By: Miah Ekholm https://css-tricks.com/almanac/selectors/c/checked/#comment-1602541 Wed, 29 Jun 2016 17:03:56 +0000 http://css-tricks.com/?page_id=14166#comment-1602541 Lines below is a perfect working Submenu example. Shortest code?
Guess what

Working Submenu

input[type=checkbox] + div {display:none} input[type=checkbox]:checked + div {display:inline-block}

]]>
By: joedeo https://css-tricks.com/almanac/selectors/c/checked/#comment-1602340 Tue, 21 Jun 2016 06:08:01 +0000 http://css-tricks.com/?page_id=14166#comment-1602340 In reply to TSF NAEM.

Sadly putting the label after the relevant field means that the field/label pair are not accessible according to the WCAG 2.0. There are a lot of examples of this field + label pattern out there but in order for the markup to make sense to all users and assistive technology the label should come first.

I await the day we can use selectors which target the preceding item

]]>
By: trial https://css-tricks.com/almanac/selectors/c/checked/#comment-1602104 Thu, 09 Jun 2016 07:38:49 +0000 http://css-tricks.com/?page_id=14166#comment-1602104 vgjdfighbn

]]>