Open In App

How to add custom google search bar inside your web-page?

Last Updated : 28 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

A search bar is necessary for a good website. Creating your own search engine from scratch might be a difficult task but this task can be skipped with the help of Google. Google has created a website to create a custom search bar, to create your own check the below link.

  • https://programmablesearchengine.google.com/about/

    .

Creating a Custom Search Bar: On this website, anyone can easily program their search bar by just selecting the sites you want to be searched for. Follow the steps explained below.

  • Step 1: Go to the following site and hit Get Started button.
  • Step 2: Select the New search engine button to create a new search engine.
  • Step 3: Fill the details as directed on the page and then click the create button.
  • Step 4: After hitting create you will get your code by hitting the Get Code button on the screen shown.

Note: You can modify your setting about searching sites, searching images, safe search from control panel and you can also set to show advertisement while searching through your search bar.

Embedding the Search Bar on a Webpage: After getting your code you can simply paste it inside your web page to see the working search bar.

  • Example: You can see that the output screen has a search bar with an option to search which shows the result from the sites or domain you have selected while creating this search bar. Moreover, this search option will automatically change as you change the sites from the control panel. Currently, the search results are been shown in the default manner. Apart from that, you can manipulate the result displaying manner and much more as directed on the below links
    https://developers.google.com/custom-search/docs/element

    .

    HTML




    <!DOCTYPE html>
    <html>
        <head>
            <title>Custom Search-Bar</title>
            <style>
                body {
                    background-image: linear-gradient(to left, white, green);
                    color: lawngreen;
                }
            </style>
        </head>
        <body>
            <h1 style="text-align: center;">GeeksforGeeks</h1>
            <script async src=
            </script>
            <div class="gcse-search"></div>
        </body>
    </html>

    
    

  • Output:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads