Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
input:required {
    background-color: yellow;
}

</style>
</head>
<body>

<h3>A demonstration of the :required selector.</h3>

<p>An optional input element:<br><input></p>

<p>A required input element:<br><input required></p>

<p>The :required selector selects form elements with a "required" attribute.</p>

<p>The :required selector is not supported in Internet Explorer 9 or earlier versions.</p>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy