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

28 May, 2020
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/.
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 linkshttps://developers.google.com/custom-search/docs/element.HTMLHTML<!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="https://cse.google.com/cse.js?cx=007019498718139788174:amtiepdpgeg">        </script>        <div class="gcse-search"></div>    </body></html>
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="https://cse.google.com/cse.js?cx=007019498718139788174:amtiepdpgeg">        </script>        <div class="gcse-search"></div>    </body></html>
Output: 
HTML-Misc
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Remove elements from a JavaScript Array
File uploading in React.js
How to Open URL in New Tab using JavaScript ?
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?