How to choose an input tag if you follow the span tag?
You can use the + selector to select all the <span> elements that are placed immediately after the <input> elements
If you want to select <input> , which is placed before <span> . this is not feasible in css since
Cascading style sheets: a cascade is like a waterfall, no reverse movement. So, of course, that there is no previous siblings selector in CSS.
Read more https://www.wikitechy.com/technology/previous-sibling-css-selector/
what you can try is .prev() jQuery ..
$(document).ready(function(){ $('span').prev().css('background','yellow'); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text"> <span>test</span> For more information about .prev() https://www.w3schools.com/jquery/traversing_prev.asp
You can make an adjacent selector using:
input + span { opacity: 0; transition: all 0.3s; } or you can make a generic selector using:
input ~ span { opacity: 0; transition: all 0.3s; } Read more ... http://cssmenumaker.com/blog/10-handy-css-selectors/