I am trying to display or hide a paragraph in a html page. The html code is:
<input type="checkbox" id="show"> Show/Hide <p id="toggle">Lorem ipsum dolor sit amet</p> </div> Then I use CSS3 to hide/show the paragraph:
#toggle { display:none; } #show:checked ~ p { display: block; } This does work. But if I try:
#toggle { display:none; } input[type='checkbox']:checked ~ p { display: block; } this doesn't work anymore. I can't understand why. Is there any error in this selector?
input[type='checkbox']:checked Thanks for helping!!!
#show:checked ~ p#toggle.. ID selector is more specific so the checked style never apply