Search engines such as Google use an algorithm or set of rules to determine what pages to show for any given query. These algorithms have evolved to be extremely complex, and take into account hundreds or even thousands of factors for determining the rankings of their SERPs.
However, there are three core metrics that search engines evaluate to determine the quality of a site and how it should rank:
Links:
Links from other websites play a key role in determining the ranking of a site in Google and other search engines. The reason being, a link can be seen as a vote of quality from other websites, since website owners are unlikely to link to other sites which are of poor quality. Sites that acquire links from many other sites gain authority in the eyes of search engines, especially if the sites that are linking to them are themselves authoritative.
Content:
In addition to looking at links, search engines also analyze the content of a web page to determine if it would be relevant for any given search query. A large part of SEO is in creating content which is targeted towards the keywords that search engines users are searching for.
Page Structure:
The third core component of SEO is page structure. Because web pages are written in HTML, how the HTML code is structured can impact a search engine's ability to evaluate a page. Including relevant keywords in the title, URL, and headers of the page and making sure that a site is crawlable are actions that site owners can take to improve the SEO of their site.
The search engine optimization process involves optimizing each of these core components of search engine algorithms in order to rank higher in the search results.
SEO is typically divided into two main groups:
On page SEO:
Everything on the page. This includes everything the words in the content you use to all the technical stuff (i.e. tho code) like the HTML tags that tell the search engines about your content. This is all within your control.
Off page SEO:
Everything off the page. This is primarily made of links to your website from other websites. This is not in your control, but you have some ability to influence it.