The text of an "HTML ratio" refers to the amount of text on a page against the code on the same page.
How to do this calculation, I know I should have to get the DOM probably, but the part exactly what elements and how the caculo works?
The text of an "HTML ratio" refers to the amount of text on a page against the code on the same page.
How to do this calculation, I know I should have to get the DOM probably, but the part exactly what elements and how the caculo works?
The HTML ratio is nothing more than the percentage of actual text in your html page. In an HTML page we have the Text and the HTML Code, the apportionment is the percentage of text in the page (code + actual text). A simple rule of three would be:
code ------- 100%
textoReal --- x
ratio = x;
For example, when loading a page it is 80kb in size. When calculating the texts of this page, we can see that of these 80kb, 60kb is just code (html tags, and everything else written other than plain text) and real text it has only 20kb. So we would have 20% text. This is our Code Rate.
80 ------- 100%
20 ------- x
ratio = (20 * 100) / 80;
ratio = 25%;
Well, some search engines use the html ratio to index your site.
If a better position on Google is not enough, for example, having a good apportionment helps SERP's (The way your page appears, usually the title and two or three lines of description).
There is no pattern to be followed, because you do not know what the search algorithm looks like and what it uses to index the pages, but the recommended one is around 20-80% of your page.
No, the apportionment of text is only one of the factors for indexing, and is not used by all mechanisms, and its relevance is not known. The best thing to ensure a good place, is to have good content and apply the other practices of seo that exist.
Remember that just as you apply seo practices, other programmers also apply. Do not just use seo on your site that will ensure good indexing.