Is it bad to use uppercase letters for html tags?

pown picture pown · Nov 6, 2013 · Viewed 36.6k times · Source

What is the best practice?

 <HTML> or <html>

And why we should stick with one particular case?

However all browsers seems to interpret both cases and returns the expected output.

Answer

Spudley picture Spudley · Nov 6, 2013

The lower-case "requirement" is a legacy of xHTML, which explicitly required it.

Plain old HTML on the other hand does not follow the rigid struct requirements of XML, and does not therefore have the fixed requirement for use of case.

However developers have tended to stick with lower case as a convention anyway, mainly on the grounds that it's a lot easier to read when you're working on it, and easier to type. But it is only a convention; there's nothing forcing it. If you have existing code with upper case tags, they will work, and there's nothing stopping you continuing to write your tags that way.

One other thing to be aware of though: In all browsers, when the browser loads the HTML document and parses it, it converts it into a DOM (Document object model). If you then use the browser's built-in developer tools to inspect the site, when you view the DOM, all elements in the DOM will be shown as lower case, regardless of how they were written in the actual source code.

For this reason, if you stick with lower case, you'll find it easier to work with the developer tools, because the code you see in the DOM view will be more consistent with the source code you've written.