Using the <form> element, implement a simple search page that accepts a question from the user and redirects it to the Google search page.
Requirements:
- Create a search input field.
- Submit the request using an HTML
<form>. - Redirect the user to Google search results.
- Style the page using CSS.
This project implements a minimal search interface that works as a front-end wrapper for Google search.
The page includes:
- A centered search form
- Text input field for the user query
- Submit button to send the request
- Automatic redirection to Google search results
When the user submits the form, the browser sends a GET request to Google with the query parameter.
Example:
[https://www.google.com/search?q=star+wars](https://www.google.com/search?q=star+wars)
/project
├─ index.html
└─ CSS/
└─ style.css
This homework focuses on practicing:
- HTML forms
- GET requests
- Using external services (Google search endpoint)
- Basic CSS positioning and centering
The form sends a request directly to Google's search endpoint:
<form
name="search"
action="https://www.google.com/search"
method="get"
></form>Important details:
action→ defines the URL where the form data is sentmethod="get"→ sends the query in the URL
The input field uses the name q, which is the parameter Google expects for search queries.
<input
type="text"
name="q"
placeholder="Find..."
autofocus
/>Example generated URL:
https://www.google.com/search?q=coffee
The form is centered on the page using absolute positioning and transform.
form {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}This technique moves the form to the center of the viewport.
Simple padding is applied to improve usability.
input {
padding: 0.3rem;
}
button {
padding: 0.3rem 0.6rem;
cursor: pointer;
}-----------------------------
| |
| Ask anything: |
| [ Find... ] [Search] |
| |
-----------------------------
The search form appears centered on the page.
- Open
index.htmlin a browser. - Type any search query.
- Click Search.
- The browser will redirect to Google search results.
Status: ✅ Completed
Features implemented:
- HTML form with GET request
- Google search integration
- Centered layout with CSS
- Simple and clean UI
MIT License
Made with ❤️ using HTML + CSS by Sam Malikin