SIDENOTE: Before everyone tells me about google\'s custom search engine, I have been using that until now but i find it really hard to style that search box and it broke on my
I have found another thread that was asking exactly what i wanted here: Add Google search in web page
Here is the code snippet for the lazy:
You just need to set the form method to "get", add one extra hidden element with the site you want to search and it will automatically paste it behind the URL as such:
<form action="https://google.com/search" method="get">
<input type="hidden" name="sitesearch" value="http://acme.com" />
<input type="text" name="q" />
</form>
Because that is how HTML forms work by default
What about such construction:
<form role="search" method="get" action="https://www.google.com/search?q=site:reddit.com+x">
<div class="search-control">
<input type="search" id="site-search" name="x"
placeholder="Search the site..."
aria-label="Search through site content">
<button>Search</button>
</div>
</form>