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-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: black;
}
input{
height: 30px;
font-size: 16px;
padding: 0 0 0 5px;
width: 20%;
border-width: 1px;
border-color: #9615DB;
border-style: solid none solid solid;
border-radius: 6px 0 0 6px;
outline: none;
background-color: #d2d3d3;
}
button{
background-image: url(images/icons8-search.svg);
background-color: grey;
background-repeat: no-repeat;
background-size: 45%;
background-position: center;
cursor: pointer;
height: 32px;
width: 50px;
outline: none;
border: none;
border-radius: 0 6px 6px 0;
border-width: 1px;
border-color: #9615DB;
border-style: solid solid solid none;
}
button:hover{
opacity: 0.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
Comments