Why does the browser need information about the type of raw text it will display?

Question

Why does the browser need information about the type of raw text it will display?

Answer

The browser needs this information so that it can give text meaning within the larger context of the document. In other words, the browser uses this information not only for rendering purposes but also so that it can create a structure which other programs (screen readers for example) can interpret.

49 Likes

Considering that all aspects of a web document present from raw text files, we need to distinguish one purpose from another. For this purpose files have a MIME type in their header. text/html says the file is a document source, text/css says it is a style sheet, text/javascript says it is a script file. Each of these MIME types require a different parsing engine for the purpose of loading them into the namespace.

10 Likes

Because the languages that structures the raw text whose browser must convert the content are not the same. The are HTML; CSS; JavaScript for exemple.

3 Likes