我正在尝试使表单中的必填字段显示为红色,但我没有任何运气。下面是我的表单和我尝试过的 css。
联系人.html
<h2>Send us an email...</h2>
<br/>
<ul>
<li>
<label for="senderName" >Your Name</label>
<input type="text" name="senderName" id="senderName" required="required" placeholder="Please type your name" maxlength="40" />
</li>
<li>
<label for="senderEmail" >Your Email Address</label>
<input type="email" name="senderEmail" id="senderEmail" required="required" placeholder="Please type your email address" maxlength="50" />
</li>
<li>
<label for="message" style="padding-top: .5em;" >Your Message</label>
<textarea name="message" id="message" placeholder="Please type your message" required="required" cols="80" rows="10" maxlength="10000"></textarea>
</li>
</ul>
<div id="formButtons">
<input type="submit" id="sendMessage" name="sendMessage" value="Send Email" />
<input type="button" id="cancel" name="cancel" value="Cancel" />
</div>
</form>
样式.css
label[required=required]{
color: darkred;
}
label[] > input[required="required"] {
background: red; }