Html Forms With CSS Focus Style Code
<!DOCTYPE html>>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="nav.css">
<title>Html Form</title>
</head>
<body>
<p>In this example, we use the :focus selector to add a background color to the text field when it gets focused (clicked on):
</p>
<form>
<label for="fname">
First name::
</label><br>
<input type="text"id="fname"placeholder="You First Name"><br>
<label for="lname">
last name::
</label><br>
<input type="text"id="lname"placeholder="You Last Name"><br>
</form>
</body>
</html>
CSS Style Focus Style
input[type=text]{
width:100%;
padding:12px 20px;
margin:8px 0;
box-sizing: border-box;
border:1px solid #555;
outline: none;
}
input[type=text]:focus{
background-color: red;
}
No comments:
Post a Comment