How search engines work
When talking about search engines it is important to remember that search engines are not humans but text-driven computers, they do not care about how your website looks but what is written on it. When talking about the search engine process there is a difference in the crawling, indexing, and retrieving process.
A website is crawled by software called a spider, crawler or in the case of Google a Google bot. This means the crawler will look at the text on a website and looks for links to different pages from that website. The spider will start from URLs found on previous indexed pages but the spider can crawl webpages more then once before they gets indexed.
A web crawler does not daily visit every page as this would be unnecessary when some pages almost never change, rather would the crawler visit pages with frequent changes.
The content on the page is analyzed to determine how it should be indexed. The crawler will look for the page title, headings and meta tags and other information to be stored in index databases, the rest of the content will be stored in other databases. The main purpose of indexing is to identify a website and assign keywords that best describe the website. This is where SEO comes in hand, you want the search engine to assign the page to the right keywords.
When a search engine user looks for keywords their search strings will be matched to the index database and the search engine will return a list of best-matching pages with a short description. Possible million if not billion pages will be matched to the search string and therefor does the search engine need to calculate which pages are the most relevant.
Each search engine has his own algorithm to define which page is more relevant and deserves a higher rank in the search result. These algorithm are closely kept secret from the public else everyone would be ranked number one and the algorithm would have no use. There are some general rules which are known under webmasters which improves a website’s ranking. This is where SEO applies when you focus on these rules while creating or improving your website.