CSS :required - Style Required Field

The CSS :required pseudo-class is used when we need to style FORM ELEMENTs having REQUIRED attribute. For example:

HTML with CSS Code
<!DOCTYPE html>
      input:required {background-color: #ccc; padding: 6px; font-weight: bold;}

      Username: <input type="text" required><br/><br/>
      Email ID: <input type="email"><br/><br/>
      Password: <input type="password" required><br/><br/>

Email ID:


CSS Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube