CSS的作用:必需的选择器
使用CSS:required选择器设置<input>的样式。具有“必需”属性的元素。您可以尝试运行以下代码来实现:required选择器:
示例
<!DOCTYPE html>
<html>
<head>
<style>
input:required {
background-color: orange;
}
</style>
</head>
<body>
<form>
Subject: <input type = "text" name = "subject" value = "C++"><br>
Student: <input type = "text" name = "student" value = "Amit" required><br>
</form>
</body>
</html>