Forum Moderators: open

Message Too Old, No Replies

capital vs. lowercase

which is better?

         

seashell

1:55 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



When I first learned HTML, I always typed my code in lowercase. Not for any reason, just because I was lazy.

Then I took a college class and my instructor taught us to code in capital letters because it's easier to read through, and distinguish code from content.

Now, I'm seeing advice on using lowercase again. Who's right? I'm tired of converting my code back and forth.

Sinner_G

2:03 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AFAIK, it doesn't make any difference. I personally use lowercase simply because I find it easier to read.

Macguru

2:05 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use capitals for tags and lowercase for attributes. Nowadays, most HTML editors will automatically apply a different colour to TAGS, attributes, scripts and content. Since it does not interfere on how browsers render the code, it does not matter. As long you are not working in a team with strict requirements about this, be lazy all you like! ;)

BlobFisk

2:59 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm an all lowercase person myself (although I use capitals in CSS IDs and classes eg: daClass, firstId).

AFAIK, XHTML should be written in all lowercase - unless called for specifically (DOCTYPE, CDATA etc.).

drbrain

4:18 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lowercase. It is more compressible if you're using content-encoding. Be aware that class and id attributes are case-sensitive, so if you change them you need to update your CSS to match. XML is case sensitive, so HTML and html mean entirely different things in XHTML (HTML is not an element in an XHTML document).

korkus2000

5:36 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Lowercase since, as mentioned above, XHTML requires it.

limbo

5:55 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To be extremely pedantic:

How many bits does an upper case sentence add to a page compared to a lower case sentence? I imagine the differece would be in favour of lower case but by how much? even on larger pages is the difference even noticable?

Still, every little counts :)

seashell

7:06 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



If I don't use XHTML is it still relavent? I see most votes are for lowercase, which I can dig, but is it worth the effort to convert previously created pages?

jbinbpt

7:11 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes it's still revelent. When you need to update those pages for other reasons, then change your tags to lowercase. It's not worth the effort otherwise.

Alternative Future

7:13 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lowercase also, even though most of our java developers have this thing for UPPERCASE.

But in answer to your question i think lowercase is more understandable.

limbo has a point some years ago this was a much more valid point.

-gs

jatar_k

7:21 pm on Sep 23, 2003 (gmt 0)

g1smd

8:26 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Lower case or Upper case does not make any different to the file size at all (to answer one question posed above) as each character is represented by 8 binary bits, or one byte.

In HTML 4 it is recommended to use all lower case. In XHTML it then becomes a requirement.

Reflection

10:44 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



In XHTML it then becomes a requirement.

Which is a good reason to start using lower case now, rather than having to break the uppercase habit later. Would I convert previously created pages? Probably not, but of course it can get a little messy when you mix the two, so it depends on how picky the person you are working for is about how the code 'looks'.

drbrain

11:09 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Lower case or Upper case does not make any different to the file size at all (to answer one question posed above) as each character is represented by 8 binary bits, or one byte.

This is correct for a raw file, but is not true if you are using content-encoding to compress your file during transfer to a user's web browser. Files with all lowercase elements and attributes are more compressible than files with uppercase elements and/or attributes. See: Simple Test of Compressing HTML Using ZLib [w3.org]

EliteWeb

11:13 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I do all my HTML coding in lowercase and all the text for the website in capitals. Readers see it better that way :)

hartlandcat

6:33 am on Sep 24, 2003 (gmt 0)

10+ Year Member



Always all in lower case.

Another thing I've never understood... why do some people type their HTML like this (ignore the underscores, this forum doesn't seem to let you have extra spaces:
<table>
_ _ _<tr>
_ _ _ _ _<td>
_ _ _ _ _ _ _<p>
_ _ _ _ _ _ _ _Blah blah blah.
_ _ _ _ _ _ _ </p>
_ _ _ _ _</td>
_ _ _ _ _<td>
_ _ _ _ _ _ _<p>
_ _ _ _ _ _ _ _Blah blah blah.
_ _ _ _ _ _ _</p>
_ _ _ _ _</td>
_ _ _</tr>
</table>

I always do mine like this:
<table>
<tr>
<td>
<p>
Blah blah blah.
</p>
</td>
<td>
<p>
Blah blah blah.
</p>
</td>
</tr>
</table>

Sinner_G

7:21 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hartlandcat, this is just a way to better see which tags belong to each other, especially if you have nested tables. I.e. does a </table> tag belong to that first or to that second <table>. Makes it easier to yourself and others to read the code.

MonkeeSage

7:31 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use all lowercase out of preference in HTML, and for all the X markup that requires it.

I indent all markup (3 spaces) out of preference because I always indent code or else I can't read it when I come back later if it is not indented; at least, not without basically going through it all again. Especially with alot of nested conditionals in code or nested elements in markup.

Jordan

BlobFisk

10:21 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<!-- I COMMENT IN CAPITALS -->
<tr>
<td>And I always use indents!</td>
<td>It's easier to read the code</td>
</tr>

However, when everthing is ready to go I strip out all unnecessary whitespace in the build version.

ergophobe

6:02 pm on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




This is correct for a raw file, but is not true if you are using content-encoding to compress your file during transfer to a user's web browser.

This forum always amazes me - I would never have thought to test this. A byte's a byte isn't it.

Thanks drbrain.

drbrain

4:40 pm on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ergophobe: Compression looks for patterns, so the more patterns (similar bytes) you have, the better comrpession you can get. For example, the 'or' in 'color' matches up with 'or' or 'selector' or 'inform' or any number of different everyday english words. If you have this in all caps, it won't.

If you're interested in this kind of thing, search for entropy and information theory.

ergophobe

5:13 pm on Sep 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Drbrain,

I understand that and it made immediate sense when I thought about it, I just would never have thought about it! That's why I was amazed.

Tom