HTML is not a case sensitive language. So why should the DOCTYPE be in capitals?
In a word, convention.
As for case sensitivity, it still applies where XML conforming documents are concerned. Guess what folks, JSX and React are XML conforming.
If neither of those is a concern, then by all means continue with the assumption that case insensitity exists. We still come back to convention. The thing that can only be attributed to unwritten rules. Write HTML in UPPERCASE at one’s own peril.
The thing to keep in mind is that the document type declararation is not HTML or XML. It is SGML, the parent schema of the whole shebang, and IT is case insensitive. After that, the other paradigms shed their own light.
Soooooo don’t write in uppercase?, which would circle back to the original issue of why doctype was in uppercase.
The DTD is not HTML, and nor is it XML. It is SGML. The case doesn’t matter.
Or does it? The easiest way to confirm this is to create a series of pages using all available DTD’s and validate each one using validator.w3.org
.
SQL makes it a common practice (for readabilities sake) to capitalize statements:
SELECT * FROM Customers;
However, it is also valid in SQL not to capitalize on the above example:
select * from customers;
If you were to inspect your browser (for which I am using Chrome in case another browser shows otherwise) you would find the DOCTYPE not capitalized.
So, one could conclude it is a matter of readability and possibly previous standards that have now become less applicable due to improvements in syntax structure and computer technologies.
Nothing has changed. Recall, the DTD is not HTML.
You are correct sir. I probably should have said it more generally because it was something I wasn’t entirely familiar with. Thank you for your reply.
Hello @mtf, thank you so much for all of your help.
Am I correct in my understanding that the following two declarations would function the same?:
<!DOCTYPE html>
<!doctype html>
If so, should we still opt to write DOCTYPE in uppercase as it is the convention?
Would writing DOCTYPE in uppercase come across as more polished/professional in the eyes of more experienced programmers?
Thank you in advance for any insight you can provide!
I don’t think it has any bearing on how it comes across. Either works the same and means the same thing. It’s my personal preference to use uppercase, but that is maybe more stubbornness or habit than anything.
Bottom line, if you are working in an organization they will very likely have their own style guide and conventions which it would be best to adopt and follow so your work matches with your colleagues’.
Doctype declarations are NOT case-sensitive, so you can write <!doctype html>
, < !doctype HTML>
, or even <!doCtYPe hTMl>
, for all you care. Also try saving it with a .htm
extension; it is perfectly valid and one less letter to spell incorrectly.