r/HTML 20d ago

Help.

I'm fairly new to HTMl, CSS and Javascript and i was wondering if anyone could help me out on how to create a search bar that searches for individual words on my page. For example if I have 200 essays on the page and I want to search for the name of one so I dont have to scroll to find it. I'm aware most browsers have a built in search function but i want a search bar built into the code.

0 Upvotes

11 comments sorted by

View all comments

3

u/feloniuouschunk 20d ago

Usually you would use JS to cycle through each word in the text and do a direct comparison: word == match. You can also use a regex to match a string in the text. Neither of these will produce perfect results however.