Code View versus Design View

The beauty of web page development is that the tools usually allow you to work directly with the code or in WYSIWYG design view. However, it is rarely possible to complete a project of any size efficiently using only one of the techniques, although working with code directly does give the developer complete control of the end product.

Pros and cons

Code View advantages
  • Developer has total control over the code produced.
  • Intellisense and Toolbox make code generation a straightforward process.
  • Code Snippets can automate repetitive sequences of XHTML code.
  • Non-visual elements can be entered precisely.
Code View disadvantages
  • Developer needs to be totally familiar with XHTML.
  • Lack of feedback with respect to the visual effects of the code.
  • Easy to get lost in a mass of tags.
Design View advantages
  • Immediate feedback about the visual presentation of the content.
  • Intuitive approach - natural typing without worrying about syntax.
Design View disadvantages
  • Easy to lose control of the code, e.g. inadvertently adding styling effects.
  • None visual elements difficult to control and enter correctly.

Strategy

Having explored the advantages and disadvantages of each we can come up with a strategy for using both views efficiently and to the benefit of the project.

When to use Code View
  • When transferring the page structure (using <div> elements) into your template. This is because it is difficult to work with nested <div> elements in the absence of content.
  • If you have a code snippet which you need to add to your page.
  • To reformat the XHTML code.
  • To verify that content entered in Design View is correctly structured.
  • Working in the <head> section of the page.
When to use Design View
  • For entry of straightforward content made up of simple XHTML elements, e.g. <h?>, <p>, <ul>, <a>, <img> etc.
  • When entering special characters, which would otherwise require use of entities, e.g. &amp; for & and &lt; for <.
  • Working with images and thumbnails.

Summary

It is not unusual for a developer to switch between Design View and Code View regularly. The decision will usually be made because of the relative efficiency of working on one rather than the other for different tasks.

If you want a good reason for using both there are plenty of examples of pages out on the Web which have been created in Design View only and suffering from bloat (excess of XHTML elements) and blight (use of non-standard techniques created by trying to force Design View to perform visual layout, rather than leaving it to CSS).

Valid XHTML 1.0! | Valid CSS! | WCAG Approved AA
Page design by: John P Scott - Hosting with: Netcetera