This is a basic search bar, for you all to use in your websites! Here is the source code:

<!DOCTYPE html>

<html>

  <head>

    <title>

      Search bar!

    </title>


    <style>

      

      body {

        background-color: white;

        font-family: fantasy;

      }

      

      #button, #p {

        font-size: 25px;

        padding: 8px;

        font-family: fantasy;

        font-weight: bold;

        border: solid 3px rgb(0, 0, 0);

        border-radius: 3px;

      }

      

      #button {

        background-color: lightgrey;

        cursor: pointer;

      }

      

      #button:hover {

        opacity: 0.8;

      }

      

      #button:active {

        opacity: 0.5;

      }

      

      #p {

        background-color: rgb(250, 250, 250);

      }

      

      #p2 {

        display: inline-block;

        width: 600px;

        font-size: 25px;

        font-family: fantasy;

        font-weight: bold;

      }

      

      #p3 {

        display: inline-block;

        width: 600px;

        font-size: 25px;

        font-family: fantasy;

        font-weight: bold;

      }

      

      #img {

        width: 100px;

        margin-left: 20px;

      }

      

      

    </style>

    

    <script>

      

      function submitSearch() {

        const output = document.getElementById('p').value;

        document.getElementById("p2").innerHTML = "Showing results for " + output + ":";

        

        document.getElementById("p3").innerHTML = "Sorry, we couldn't find what you were looking for.";

        

document.getElementById('img').src = "

";     

 }

      

    </script>

  </head>  

  

  <body>

    

    <input type="text" placeholder="Search..." id="p">

    <input type="submit" id="button" onclick="submitSearch()">

      <br>

    <p id="p2">

      

    </p>

      <br>

    <p id="p3">

      

    </p>

      <br>

    <img id="img">

  </body>

</html>

Leave a comment

Log in with itch.io to leave a comment.