CSS3 > Selectors

Focus selector in CSS3

How to select the element that has focus in CSS3?

By using focus selector we can select the element that has focus.

        input:focus {
            border: 2px solid double;
            background-color: pink;

            <legend>Enter Details</legend>
            <input type="text" name="user" /><br />
            <input type="password" name="password" />
            <br />
            <input type="button" value="Submit" />

In the above code snippet we have given style focus to the <input> elements. The colour of the text box changes by clicking inside the text box, that means the element got focus by the focus selector.


 Views: 3486 | Post Order: 24

Write for us

Hosting Recommendations