How does the browser know what language other documents are written in? For example, why doesn’t css need a doctype?


#1

Question

How does the browser know what language other documents are written in? For example, why doesn’t css need a doctype?

Answer

DOCTYPE declarations are only required for html based documents. Other JavaScript or CSS files are actually loaded into the page with <link> or tags. These tags signify the file type to the browser thereby allowing the browser to properly parse the file.


FAQ: Learn HTML Elements - Common HTML Elements - Preparing for HTML
#2

Why is DOCTYPEtag needed to identify the file is HTML when the file already starts with
and ends

Isn’t this requirement tautological?