# Keyword density

Keyword density is the percentage of times a keyword or phrase appears on a web page compared to the total number of words on the page. In the context of search engine optimization keyword density can be used as a factor in determining whether a web page is relevant to a specified keyword or keyword phrase.

In the late 1990s, which was the early days of search engines, keyword density was an important factor in how a page was ranked. However, as webmasters discovered this and the implementation of optimum keyword density became widespread, it became a minor factor in the rankings. Search engines began giving priority to other factors that are beyond the direct control of webmasters. Today, the overuse of keywords, a practice called keyword stuffing, will cause a web page to be penalized.

Many SEO experts consider the optimum keyword density to be 1 to 3 percent. Using a keyword more than that could be considered search spam. The formula to calculate your keyword density on a web page for SEO purposes is ${\displaystyle (Nkr/Tkn)*100}$, where Nkr is how many times you repeated a specific keyword and Tkn the total words in the analyzed text. This will result in a keyword density value. When calculating keyword density, be sure to ignore html tags and other embedded tags which will not actually appear in the text of the page once it is published.

When calculating the density of a keyword phrase, the formula would be ${\displaystyle (Nkr*Nwp/Tkn)*100}$, where Nwp is the number of words in the phrase. So, for example, for a page about search engine optimization where that phrase is used four times and there are four hundred words on the page, the keyword phrase density is (4*3/400)*100 or 3 percent.

However, from a purely mathematical viewpoint, one cannot ignore the fact that the original concept of keyword density refers to the frequency (Nkr) of appearance of a particular keyword in a dissertation. Thus, a "keyword" consisting of multiple terms, e.g. "blue suede shoes" should be considered an entity in itself. It is the frequency of the phrase "blue suede shoes" within a dissertation that drives the key(phrase) density. Thus it is "more" mathematically correct for a "keyphrase" to be calculated just like the original calculation, but considering the word group, "blue suede shoes," as a single appearance, not three. Thus:

Density = ( Nkr / Tkn ) * 100.

Furthermore, under closer inspection, one can see that these 'keywords' (kr) that actually consist of several words, artificially inflate the total word count of the dissertation. Therefore, it could be argued that the purest mathematical representation should adjust the total word count (Tkn) lower by removing the excess key(phrase) word counts from the total. Thus:

Density = ( Nkr / ( Tkn -( Nkr * ( Nwp-1 ) ) ) ) * 100. where Nwp = the number of terms in the keyphrase.

This general formula allows that the total word count will be unaffected if the key(phrase) is indeed a single term, so it acts as the original formula.