CSS3 > Selectors

Required selector in CSS3

How to add style to the required form elements in CSS3?

By using required selector we can add style to the required elements. Required selector is only applies to the form elements (input,elect and text area).

    input:required {
        background-color: pink;

    <h3>Required selector</h3>
        First name
        <input type="text" name="txt" required />*<br />
        Middle name
        <input type="text" name="txt" /><br />
        Last name<input type="text" name="txt" required />*

In the above code snippet we have given style to the required selector. So, that it will find the required attribute in the <input> elements and applies the given style.


 Views: 3104 | Post Order: 32

Write for us

Hosting Recommendations