Using the :focus Selector

Description

:focus selects elements with focus.

Example

The following code uses the :focus Selector.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:focus {<!--from   www  . ja v  a 2s  .co  m-->
  border: thin black solid;
  padding: 4px;
}
</style>
</head>
<body>
  <form>
    Name: <input type="text" name="name" />
    <p />
    City: <input type="text" name="city" />
    <p />
    <input type="submit" />
  </form>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table