:required Back

  • :required is a CSS pseudo-class selector used to select form elements that are required.
  • More specifically, it is used to select form elements that have the required attribute set.
<input type="name" required>

<input type="checkbox" required>

<input type="email" required>

<!-- and other input types as well.. -->

<textarea name="name" id="message" cols="30" rows="10" required></textarea>

<select name="nm" id="sel" required>
    <!-- options -->
</select>

Case: learning :required

See the Pen WrBOYB by aleen42 (@aleen42) on CodePen.

Note

  • If you want to select form elements that are optional, you can use the :optional pseudo-class selector.

Copyright © aleen42 all right reserved,powered by GitbookUpdated time: 2016-10-09 06:25:23