Anyone have any examples of how they have or would use these in real-life?
Anyone have any examples of how they have or would use these in real-life?
input:valid + label { color: black; }
input:invalid + label {color: red; }
CSS Tricks has a tutorial (http://css-tricks.com/float-labels-css/) on this technique for displaying form labels as faux placeholders until the input has content, although it's not quite ready for most site's production requirements.
I haven't found many uses for the general sibling selector `~`, as it matches all elements after the initial selected element. I usually want the preceding elements as well if I'm shooting that broadly, so simply excluding the item with `:not()` is generally a better choice.
:checked + label { background-color: green; }
http://jsbin.com/witaziwu/1/edit?html,css,output Small demo if you want to mess around with it.
https://code.tutsplus.com/tutorials/the-30-css-selectors-you...