Question

Is it better for sake of compatibility/JIT-Compiling performance to use UPPER CASE or lower case, in JS/HTML? For eg:

 <DIV> my content </DIV>
 <div> my content </div>

 ALERT(DOCUMENT.LOCATION);
 alert(document.location);

This is not a newbie question, I know lowercase is the de-facto standard. But since I've seen some uppercase JS+HTML, I was wondering which would be better to write in. (like SQL is fully uppercase?)

Was it helpful?

Solution

I don't think it'd make a difference, speed-wise.

XHTML: Lowercase tags is what the W3C specified.

JavaScript: It probably wouldn't work, because I have never seen anyone's code use all caps in JS.

SQL is fully uppercase to differentiate the actions, functions, etc from the actual data. You can use lowercase, but it becomes less readable (to some, me included).

IMO, wading through a heap of uppercase tags is less readable than lowercase tags. I'd say user agents don't care what case the tags are. Here's a little bit of history: when I made a website in 1999, uppercase tags were the standard.

You can still find some dodgy non updated websites out there that still write

'Use <B></B> to make text bold'

OTHER TIPS

It is incorrect (in xhtml, at least) to use <DIV>...</DIV>; it is a <div>...</div>.

Likewise, I'd use lower-case in the javascript (for alert(document.location);), as that is their names ;-p

I can't imagine it making any difference compatibility- or performance-wise. I think some people find UPPERCASE easier to recognize as markup or code rather than content.

You can do some benchmarks, if you must.

(XHTML specifies lowercase as the standard, so if your goal is satisfying validators, then go with that)

JavaScript is (using Fx3.0) case sensitive.

var myURL = document.URL; // sets myURL to the current URL
var myURL2 = DOCUMENT.URL; // ReferenceError: "DOCUMENT" is not defined

HTML allows mixed-case tags, XHTML demands lower-case only tags, attributes.

It certainly makes a difference with javascript since it is case sensitive.

The accepted community standard for html is lowercase, even though browser don't care.

So be nice to the ones who have to read your code later!

I'd definitely go with lowercase wherever possible. I tend to like camel casing multi-word variable names, but even that can be eschewed in favor of underscores.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top