Using only HTML & CSS and without using JavaScript, how would I style the fieldset around focused form inputs differently from the rest of the fieldsets? (Basically, the same thing as this question but without JavaScript)
Below is the effect I want to achieve, currently using JavaScript:
$(document).ready(function()
{
$('input').focus(function(){ $(this).parent().addClass('jshack'); });
$('input').blur (function(){ $(this).parent().removeClass('jshack'); });
});
fieldset { border: 2px solid lightgray; }
fieldset.jshack { border: 2px solid black; }
input:focus { background-color: lightyellow; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="?" method="get">
<fieldset>
<legend>Fieldset 1</legend>
<input name="text1" type="text" />
<input name="text2" type="text" />
</fieldset>
<fieldset>
<legend>Fieldset 2</legend>
<input name="text3" type="text" />
<input name="text4" type="text" />
</fieldset>
</form>
Desired end result should be identical visually but should not use JavaScript in any way.
UPDATE: I am not looking for the magical CSS parent selector. I am looking for recreations of the effect with CSS trickery, such as this answer which could not be posted before this was closed.