How to Write Code for Ease of Interpretation

When you write code, using the correct syntax is important for purposes of compiling — your end goal. However, the layout of your code is also extraordinarily important, so that you and others can understand and interpret what the code does.

Using white space is vital to creating good code. Because HTML does not recognize carriage returns (a term held over from the typewriter era), tabs, and extra spaces, these formatting tools can be utilized to create organization and ease of interpretation within your code documents.

Some rules to follow when coding in HTML, CSS, or any programming language:

  • Add carriage returns between blocks of code to delineate distinct segments.
  • Use tabs as you would in an outline, to keep track of what code is nested within other code.
  • Use comments (<!–HTML–> and /*CSS*/) to describe what each segment of code does.
  • Reorganize when your code becomes too messy for interpretation.

Using white space, carriage returns, tabs, and spacing also makes it much easier to debug your code, something even the best programmers need to do constantly.

And remember, always close a tag as soon as you open one so that you don’t forget to do it later.




~ by katiedigicomp on January 31, 2011.

One Response to “How to Write Code for Ease of Interpretation”

  1. I thought your post was very informative and would help someone who isn’t familiar with HTML to get a very well put together and easy to read code. The tips that you gave were helpful and with my own experience with HTML, are very effective tips. One thing you might want to add is an example of code using these tips (a screenshot or links) and possibly annotate the example for more clarification.

Comments are closed.

%d bloggers like this: