Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> /* A container to give the form a clean, centered context */ .search-form-container { max-width: 400px; margin: 40px auto; padding: 30px; background-color: #f4f6f8; border-radius: 8px; } .search-form { display: flex; /* Aligns input and button on the same line */ width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border-radius: 6px; overflow: hidden; /* Ensures child border-radius conforms */ font-family: sans-serif; } .search-form-input { flex-grow: 1; /* Makes the input field take up all available space */ border: 1px solid #ccc; padding: 12px 15px; font-size: 1rem; color: #333; } .search-form-input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); z-index: 1; position: relative; } /* Visually-hidden label for accessibility */ .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; } .search-form-button { background-color: #007bff; border: none; color: white; padding: 12px 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s; } .search-form-button:hover { background-color: #0056b3; } .search-form-button svg { width: 20px; height: 20px; } </style> <div class="search-form-container"> <form class="search-form" action="#" method="get"> <label for="search-input" class="sr-only">Search</label> <input class="search-form-input" type="search" id="search-input" name="q" placeholder="Search this site..."> <button class="search-form-button" type="submit" aria-label="Search"> <!-- Magnifying glass SVG icon --> <svg viewBox="0 0 24 24" fill="currentColor"> <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path> </svg> </button> </form> </div>