Javascript – How to put the magnifying glass and “search” in the search input box, like in StackOverflow


Assuming it is possible with just CSS, but wanted to know if someone could share the code.

Guessing the magnifying glass is a background image, but need JavaScript to remove "search" on focus.

Also, how do you get it to submit when hitting "return" rather than needing a "search" submit button?

Best Solution

There are multiple elements involved.

Use Chrome DevTools (F12) to inspect these things.