How to define the search bar in HTML: first create a new div with the id name box; then add an input tag and a div tag inside; and finally use css to style them.
The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.
How to define the search bar in HTML:
1. First create a new div with the id name box to wrap the search box;
2 , and then add an input tag and a div tag inside, one for text input and one as a button;
3. Finally, use css to style them.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Examples</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> <style type="text/css"> #box{ width: 380px; margin: 30px auto; font-family: 'Microsoft YaHei'; font-size: 14px; } input{ width: 260px; border: 1px solid #e2e2e2; height: 30px; float: left; background-image: url(images/search.jpg); background-repeat: no-repeat; background-size: 25px; background-position:5px center; padding:0 0 0 40px; } #search{ width: 78px; height: 32px; float: right; background: black; color: white; text-align: center; line-height: 32px; cursor: pointer; } </style> </head> <body> <div id="box"> <input type="search" name="search" placeholder="请输入关键字"> <div id="search">搜索</div> </div> </body> </html>
Related learning recommendations: html video tutorial
The above is the detailed content of How to define search bar in HTML. For more information, please follow other related articles on the PHP Chinese website!