CSS :focus Selector - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:focus

Description

The :focus selector selects the element with focus.

Example

Select <input type="text"> with focus

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
  width: 100px;
  -webkit-transition: width .35s ease-in-out;
  transition: width .35s ease-in-out;
}
input[type=text]:focus {
  width: 250px;
}
</style><!--from  w ww .  j a  v a 2  s. co m-->
</head>
<body>
Search:<input type="text" name="search">
URL:<input type="url" name="url">
Number:<input type="number" name="number">
Button: <input type="button" name="button">


</body>
</html>

Related Tutorials