Dreamweaver provides several different ways to view a page's HTML code:
Code view . In Code view, Dreamweaver displays your page's raw code.
Split view . This shows the HTML code and the "regular" Design view simultaneously (Figure 9-2).
Code inspector . The Code inspector is a floating code window that lets you use Design view in its full glory (not cut in half as in Split view), while still providing access to the code. (To open the Code inspector, choose Window Code Inspector, or press F10.) Code warriors who are into serious multitasking can also use the Code inspector to look at one area of code, while using the main document window to work on another area of code.
The rest of this chapter assumes that you're using Code view for HTML editing.
To move between Dreamweaver's different views, use the buttons in the Document toolbar (Figure 9-2) or choose a name from the View menu: Code, Design (the "regular" visual mode), or Code and Design (Split view).
Code view functions just like a text editor. You can click anywhere inside the window and start typing HTML, JavaScript, Cascading Style Sheet, or other programming code (such as ASP, ColdFusion, or PHP).
That doesn't mean you have to type out everything by hand; the Insert bar, Insert menu, and Property inspector also function in Code view. Using these sources of canned HTML blobs, you can combine hands-on HTML work with the easy-to-use, rapid action of Dreamweaver's objects. This trick can be a real time-saver when you need to add a table, which would otherwise be a multiline exercise in typing accuracy. You can also select a tag (an image's <img> tag, for example) in Code view and use the Property inspector to modify it.
To help you navigate your code, Code view provides several visual cues. They include:
Syntax coloring . Dreamweaver displays different elements in different colors. Comments, for example, are gray. Text is black, HTML tags appear in dark blue, and HTML properties show up in bright blue. You can change any of these colors, and even specify unique colors for different types of tags, using the Preferences window (see Figure 9-4).
To really make a tag stand out, you can underline it, make it bold, italicize it, and even give it a background color. Dreamweaver has separate color schemes for 24 different types of documents, such as ASP, CSS, and XML files. (But do you really need different colors for HTML forms in ASP pages, HTML pages, and PHP pages? You be the judge.)
Bad code highlighting . When you type incorrect code (an opening tag without a closing tag, say), it's highlighted in yellow (see Figure 9-5).
Browser error highlighting . Not all browsers understand all the HTML tags and properties available in Dreamweaver, especially since older browsers may not be aware of current standards. This feature, which is part of the Check Browser Support tool described on Section 14.2, lets Dreamweaver identify code that doesn't work with certain browsers.
Here's how you use it: In Code view, a squiggly red underline appears under code that doesn't work with the browsers you've told Dreamweaver to check (see Section 14.2.1). Mousing over the squiggly line produces a pop-up dialog box with a description of the problem.
For example, in Figure 9-5, the code <div id="sidebar"> displays with a squiggly line under id="sidebar" ; mousing over the id attribute generates a message saying that it isn't supported by Navigator 3.0. (In other words, that old Windows 95 machine in the Museum of Ancient Computing might have trouble displaying this page.)
Library Items . Library items and uneditable regions in pages built from templates appear in light gray. You can't actually change this code in Code view. This coloring scheme is a little confusing since HTML comments (see Section 9.2.1) are also displayed in gray, and you can edit those. (For more on templates and the Library, see Chapters 16 and 17.)
You can also control Code view display by using the View Options pop-up menu in the toolbar (see Figure 9-6), or by using the View Code Options submenu:
Word Wrap . This option makes long lines of code wrap (at the window's edge) to the next line, so you don't have to scroll horizontally to see it all. This option affects only how Dreamweaver displays the line in the document window; it doesn't actually change your code by introducing line breaks.
Line Numbers . This automatic line numbering can come in handy when you're using Dreamweaver's Check Target Browser tool (see Section 14.2), or when you encounter an error in a page containing server-side code (such as the code you create in Part Six of this book). You can also click a line number in Code view to select the entire line, which is a great way to delete or cut a line of code.
Hidden Characters . Some characters you can type on the keyboard aren't visible on the screen: the end of a line, created by hitting the Enter or Return key, for example. Sometimes, these hidden characters can cause big trouble. For example, when working with dynamic, server-side Web pages (described in Part Six), you might find some cool code on the Web and copy it to your own page. Sometimes copying and pasting code from a Web page introduces hidden characters that prevent the code from working. Turning on the "Hidden Characters" option can help you ferret out these problem characters and eliminate them. Spaces appear as dots, tabs as a set of greater than signs (>>), and paragraphs as a paragraph symbol ( ) (see Figure 9-6).
Highlight Invalid Code . This is the on/off switch for Dreamweaver's friendly tendency to highlight bad HTML in Code view (see Figure 9-5).
Syntax Coloring . This option turns tags, comments, and text into colorful (and informative) text (see Figure 9-4).
Auto Indent . When you're working with nested HTML tags, it's often helpful to press the Tab key to indent each level of nested tags, making it easier to identify large blocks of HTML (a table and all its contents, for example). The Auto Indent option carries the same size indent onto the next line when you hit the Return or Enter key. For example, suppose you hit the Tab key twice, type a line of code, and then hit Return. Dreamweaver would place the insertion point on the next line, indented using two tabs. To un-indent, just press the Backspace key.
Dreamweaver 8 introduces a handy toolbar that makes many basic hand-coding tasks go much more quickly. While working in Code view, the Coding toolbar appears on the left edge of the document window (see Figure 9-6). If you don't see it, you can turn it on by choosing View Toolbars
Coding, or by right-clicking (Control-clicking) on another toolbar such as the Insert or Document toolbar, and turning on the Coding option in the pop-up menu. Use the same technique to close the toolbar, if you dont use it.
The toolbar contains buttons that duplicate tasks and preference settings that you can control from other parts of Dreamweaver. Here's a quick rundown of the buttons listed in Figure 9-6, with a quick explanation of what they do and, when applicable , a cross-reference to a more detailed description of the tool or action:
Open Documents . This is just a pull-down menu, displaying all open documents. It lets you switch among the different documents you're currently working on, but it's actually more work than just clicking a document's tab at the top of the document window (see Section 1.2.1), so you'll probably want to skip it.
Collapse Full Tag/Collapse Selection/Expand All . These three buttons work with Dreamweaver 8's Code Collapse feature described on Section 9.2.3. They let you collapse (and expand) multiple lines of code, essentially keeping it out of the way, letting you concentrate on the code you're currently working on.
Select Parent Tag . This handy feature lets you quickly select the tag that surrounds your current selection. For example, say you've selected the text inside of a link (<a>) tag, or just clicked inside that tag, and your cursor's blinking happily. Click this button, and the entire <a> tag is selected. Click it again, and that link's parent tag is selected. This button provides a quick way to select the tag you're currently working on. If you really want to be productive, the keyboard shortcut Ctrl-[ ( -[) is quicker.
Balance Braces . If you do a lot of programming using JavaScript or one of the server languages like PHP, ColdFusion, or ASP, this button can help you find the matching brace ({ or }) character in a chunk of programming code. Just click to the right of an opening brace ({) and then click this button to find the closing brace. To find a closing brace's mate, click to the left of the brace , and then click this button. The button also finds matching parentheses characters. The keyboard shortcutCtrl+' ( -')is even faster.
Apply/Remove Comments . Comments are a way of including helpful notes in your code that don't appear on the page when it's displayed in a browser. You may want to leave some explanatory notes in your HTML page to help future generations of Web developers understand what you were doing. For example, you might put a comment before a <div> tag (see Section 8.4) that explains what should go inside it"For corporate logo and navigation bar." Comments are also frequently used to mark the end of a section of the page"End of navigation bar." These buttons let you add or remove comments to HTML, CSS, Java-Script, PHP, and VBScript code, as demonstrated in Figure 9-7.
Wrap tag . Works the same as the Quick Tag editor described on Section 9.2.4.6.
Recent Snippets . This pop-up menu lists all the snippets (see Section 16.1) you've recently used. Selecting an item from the menu inserts that snippet's code into your Web page.
Indent/Outdent . These buttons will indent or outdent lines of selected code using the settings you've defined in the Code Formatting preferences (see Section 9.2.4.1).
Apply Source formatting . This button lets you apply specific formatting to an entire Web page, or just a selection of code, using the code-formatting options you've set up in the Code Formatting preferences window (see Section 9.2.4.1) and the rules defined in the type-A-