top of page
Writer's pictureWeb Coding

How to create a simple search bar

Learn how to create a simple search bar using only HTML and CSS


HTML

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <input type="text" placeholder="Search..."><button title="search"></button>
</body>
</html>


CSS

body{
 min-height100vh;
 displayflex;
 align-itemscenter;
 justify-contentcenter;
 background-colorblack;
}

input{
 height30px;
 font-size16px;
 padding0 0 0 5px;
 width20%;
 border-width1px;
 border-color#9615DB;
 border-stylesolid none solid solid;
 border-radius6px 0 0 6px;
 outlinenone;
 background-color#d2d3d3;
}

button{
 background-imageurl(images/icons8-search.svg);
 background-colorgrey;
 background-repeatno-repeat;
 background-size45%;
 background-positioncenter;
 cursorpointer;
 height32px;
 width50px;
 outlinenone;
 bordernone;
 border-radius0 6px 6px 0;
 border-width1px;
 border-color#9615DB;
 border-stylesolid solid solid none;
}

button:hover{
 opacity0.7;
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on


YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

48 views

Comments


bottom of page