Enhancing User Interaction with the :focus Pseudo-Class in CSS


Focus

Source Code :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Input pseudo-classes</title>
    <style>
      input {
        outline: none;
      }
      input:focus {
        border-color: blue;
        border-radius: 3px;
      }
    </style>
  </head>
  <body>
    <h3>Input pseudo-classes</h3>
    <p>:focus</p>

    <input type="text" placeholder="first name" id="fname" />
    <input type="text" placeholder="last name" />
  </body>
</html>

Live Preview


CSS Tutorial


Properties Reference


Cascading Style Sheet


Flexbox Tutorial


CSS Grid Tutorial


Transitions Properties


CSS Properties with Examples


CSS Selectors


CSS Pseudo Elements


CSS Attribute Selectors


Input Pseudo Classes


CSS Examples


CSS Animation Projects