The text-to-code ratio describes the relationship between text content and the underlying source code of a website. Each website consists of source code which initially structures the contents of the website in the background as well as the text that is readable by the users.
Considering the number of characters that the source code (also called backend) and the text (also called frontend) use, a percentage ratio can be established which is used as a text-to-code ratio in search engine optimization. This value is supposed to be at least 25% and can be checked with various tools free of charge.
Two aspects make up the background for the relationship between text and source code. One aspect is a valid source code. Secondly, HTML should be used as the markup language so that the documents comply with the recommendations of W3C.
For example, each HTML document should have exactly one H1 heading and no more. Correspondingly, other design elements should be used. To be mentioned here are sub-headings, paragraphs, and other markup such as bold text or italics. The source code is supposed to represent the content clearly. HTML tags give the content structure, but still no form. The source code itself should be kept as slim as possible. Important is the separation of content and form, or content and markup. It is highly recommended to format HTML document using CSS. The number of characters in the source code can be reduced that way.
The users are on the other side. Both the content as well as the design and the associated structure should be geared to the user as much as possible. The content and style of the markup which invite users to stay on a webpage is particularly important. Text content is the central element that transports information. The design is important for the visual impression, but the information would also be conveyed if text were less attractive.
The most important factor is that a webpage precisely communicates the intended information, such as a company description which users are searching for. Search engines usually assume that websites can only serve users’ information needs when a certain amount of text content is found. Exceptions to this are multimedia-heavy websites. The primary aim of such websites is not necessarily the transmission of information.
The following example shows you an HTML framework. 275 characters in total. Of these, 197 are characters. The text-to-code ratio thus corresponds to 100 * 197/275 = 71.64%.
<html> <head> <title>title</title> </head> <body> <h1>header</h1> <p>text</p> </body> </html>
In search engine optimization, it is assumed that the text-to-code ratio is a ranking criterion of search engine operators. It is unclear, however, to what extent this criterion applies and whether it is used for all types of websites. A website like Youtube, which offers video streaming, will have an unfavorable text-to-code ratio compared to a website that has a lot of text. But YouTube is considered one of the strongest websites on the Internet. Online shops often have thousands of product pages, which presumably have more source code than text content.
The text-to-code ratio therefore does not always have to be decisive for the ranking. Search engine operators are likely concerned about the added value for users. Websites should be edited and formatted for the user. That way, menus can be distinguished with important terms, so that users know where to go. The crawler, which can read the source code and text content, will not use Scripts or other factors that restrict accessibility.
Search engines want valid, accessible source code and relevant text content, which represent a value for the user. Both sides want a fast website, which displays all relevant content within seconds - keyword: loading time. The text-to-code ratio can thus also be interpreted as an expression of other important ranking factors and does not necessarily have to be a ranking factor in itself.