-
Files should not contain any TAB characters.
-
The indentation level for HTML markup may be as little as 2 spaces, but must be consistent, whatever the level. For program code such as JavaScript or PHP a more generous 4 spaces is probably a better choice, but 2 spaces may be convenient in cases where longer lines are frequent. Web programming tends to require longer lines than other kinds of programming, and smaller indentation levels help to avoid at least some extended lines and the resulting readability hit. Whether the smaller indentation level itself causes a readability hit is, of course, a debatable point. Indentation levels may have to vary from file to file, but should be consistent within any given file. Even this latter rule may have to be broken from time to time, if there is a good reason for doing so.
-
Unless otherwise specified, students should continue to use the same coding standards previously required for C++ and/or Java when coding in JavaScript or PHP for a web development course (except for the indentation level, as noted above).
-
CSS style sheets, unlike every other kind of markup or code file, do not require indentation or vertical lining up of braces, since readability is quite good without these requirements for the simple reason that CSS style sheets do not contain any nested structures.
CSS indentation can also be as little as 2 spaces.
-
Lines should be strictly less than 80 characters in length, unless there is no place to break the line without also breaking the required syntax. This is, in fact, a commonly encountered situation in HTML files, and one of the reasons we use such a shallow (2-space) indentation level.
-
Files should contain a comment containing at least the name of the file and possibly other identification or explanatory information, as required. Whenever possible, this comment must be at the beginning of the file.