• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Day 3. Advanced HTML and Site Tools > Direct Access to the HTML

Direct Access to the HTML

There comes a time, no matter what you're doing, when you need to have access to the HTML itself, rather than just the WYSIWYG interface. It's often easier to change a few tags by hand than to select the objects, open the Properties panel, find the appropriate attribute to change, and change it.

To view HTML within the document design window, you have two choices—either a straight code view (Code), or a code and design view (Code and Design). Switch to these modes by choosing the appropriate option from the View menu or by clicking the icons in the design window toolbar. The Code and Design mode is shown in Figure 3.24. You can toggle between all three window modes by using Switch Views from the View menu.

Figure 3.24. The Code and Design view lets you edit the HTML directly or visually.

The editor is easy to use, but offers advanced features such as syntax highlighting, automatic indentation, and code completion (for those writing server-side code). The Edit menu has several features specific to working in the code view—Indent/Outdent Code to adjust indentation, Balance Braces for JavaScript programming, and Code Hints for those writing server-side code.


If you're a programmer, you'll greatly appreciate code hints, which are active by default. These “hints” appear after typing a few characters of a server language function, allowing you to quickly auto-complete the code.

Transferring Selections Between Views

As you are editing the HTML in either the code or design view, you can select the HTML text or the objects themselves within the design view. Once selected, if you switch views, the selection also appears in the alternate view. For example, if you graphically select a table in the document design view, the <table></table> tags (and everything in between) will also be selected in the code view. On very complex pages, this makes it simple to find what you're looking for in the HTML.

Similarly, as you update HTML code, the design view is immediately updated and vice versa. If the views get out of sync, you can force a reload with the circular arrow icon in the toolbar.

Changing Line Options

Text in the HTML code display can be displayed with line numbers by selecting the appropriate options from the top-right menu of the toolbar. Line numbers are mostly useful for debugging source code of dynamic applications. You probably won't use it much while editing standard HTML.

Lines can be displayed wrapped to the length of the size of the editing window by using the Word Wrap menu selection. Although displaying the window in a non-wrapping mode makes it easier to understand the structure of the HTML, it means that you often have to scroll horizontally to find the tags you're looking for.

From this same menu, you can also choose to auto-indent code as it is entered, highlight invalid HTML tags, and color your code syntax.

Using the Quick Tag Editor

The Quick Tag Editor lets you quickly edit the HTML from within the standard design-editing mode. Selecting an object in the design window, opening the Properties panel, and clicking the icon directly below the help icon launches the Quick Tag Editor. The Quick Tag Editor simply brings up a pop-up window that contains the HTML of the tag being edited. You can change any of the HTML in the tag directly. Although this might not seem like a very important feature, sometimes you know exactly what you want to change on a tag, but you don't want to search through the source code or deal with going through an interface to find it. The Quick Tag Editor gives you exactly what you want and doesn't force you to use a GUI interface to make your changes.

If you're working in the document design window and have an item selected, you can also bring up the Quick Tag Editor by choosing Quick Tag Editor from the Modify menu. This enables you to directly access the HTML you need without needing the Properties panel.


Control+T (Windows) or Command+T (Macintosh) can be used to easily access the Quick Tag Editor.

Referencing Tag Information

To use the extensive reference capabilities of Dreamweaver MX from within the editor, you can select a tag that you want to look up, and then click the <?> button in the toolbar. Within a few seconds, Dreamweaver MX will open the Tag Reference panel and show you all the available options for a specific tag. This is a fantastic way to find additional attributes to fine-tune your HTML manually. Figure 3.25 shows the Tag Reference panel.

Figure 3.25. The Tag Reference panel contains complete information on every document tag.


The Tag Reference panel can be used at any time, not just in the design view. You can access it from the Window menu's Reference option.

Exploring Search Features

If you need to search for text or tags within the HTML, you can use the built-in find and search/replace options. The search and replace features are somewhat extensive, and should allow you to find very complex patterns within the HTML. The Edit menu contains your search options:

Find and Replace— Performs a search and replace operation on the HTML. This option also allows for Find without replace, so it can be used for all your searching needs.

Find Again— Finds the next occurrence of the search item and highlights it in the HTML.

Let's go ahead and take a look at the Find and Replace window now. Figure 3.26 shows this window in its fully expanded form.

Figure 3.26. A wide variety of options are available in the Find and Replace window.

In this example search, I've chosen to search the Current Document for the tag <td> that does not have the bgcolor attribute set. The bottom of the window shows a list of the files where a match was found and what the matching tag looks like. This detailed section of the window is normally hidden and can be toggled on or off by clicking the expansion triangle in the lower-right portion of the window.

The search and replace options are varied and can be adapted to match patterns rather than just literal strings or tags. Here's how you can modify the search and replace options so that they fit your needs.

Search Scope

Adjusting the Find In attributes lets you change what files are going to be checked. You can check the current document, the entire local site, selected files in the site, and the contents of a folder. Being able to update hundreds of files simultaneously enables you to easily fix problems that would be a nightmare otherwise. For example, if your site has hundreds of links to an external site spread throughout the source, updating those links would take an eternity if the domain name changed. A properly defined search and replace on the entire site will fix the problem in a matter of seconds.

Search Criteria

The next thing you'll need to do is specify exactly what you're searching for by choosing the appropriate option from the Find What section. The following search types are available:

Text— A text search operates only on the body text of the document—not the text within any of the tags.

Source Code— This search examines the contents of the HTML tags themselves. This is the opposite of the Text search.

Text (Advanced)— The Advanced text search lets you check the text inside and outside tags. Using the “+” and “” buttons, you add and delete attributes that you want, or don't want to find.

Specific Tag— The Tag search is similar to the advanced search, but it only searches the inside of tags.


After a search has been defined, you can click the Find Next or Find All button to perform the search, or define a Replace action that will take place on the items that are located.

Most of the search types provide a simple Replace With field to enter your text or tags. This will do exactly what you expect. If you are using the Tag search type, you can specify an attribute change action. For example, you can easily change the value of bgcolor, width, and height globally.

Search Modifiers

A few options are available that can alter a search in very dramatic ways:

Match Case— The text being searched for must exactly match the text that is found based on capitalization.

Ignore Whitespace— Because the HTML language condenses strings of spaces, it is very likely that words aren't necessarily next to each other. This will ignore extra spaces if they exist between words.

Use Regular Expressions— Regular expressions enable patterns to be searched for, rather than literal text. These will require some additional explanation.

The most powerful type of search is one in which you aren't just matching literal characters, but patterns of characters. For example, if you wanted to match anything in the text that appears to be a phone number of the format ###-###-####, there is no way to do this with a traditional search string without testing for every single possibility. Through the use of regular expressions, you can easily match that sequence of numbers with "\d{3} -\d{3} -\d{4} ". This might look a bit confusing at first, but it's quite simple. By inserting certain characters into your search string, you can create a search pattern that matches many variations of a string.

Here is a list of the regular expressions available, and an example of their use:

\w— This is an alphanumeric character. \w\w\w would match any three character string containing letters or numbers. To match anything but an alphanumeric character, use \W.

\d— This is any number. \d\d\d-\d\d\d-\d\d\d\d is an alternative version of the pattern to match a simple phone number. As with the previous tag, the \ D variation of this expression matches anything that isn't a number.

.— This is any character except a newline. h.ppy will match happy, hoppy, or any other character in the second position.

\s— This is a whitespace, such as a tab or space. happy\sday will match the word happy and day as long as there is a space between them. To match something that isn't a space, use \S.

\t— This is a tab. Field1\tField2 matches the word Field1 followed by a tab and then Field2.

\r,\n,\f— This is return, newline, and form feed. Depending on the platform that the HTML was originally created on, you might need to use one or more of these matches.

a|b— Matches either the pattern on the right or the left side. left|right will match either left or right.

[xyz]— Matches any of the characters within brackets. [012345] will match the numbers between 0 and 5. To negate this pattern, put a ^ at the front of the character list. For example, [^012345] will match any number that isn't 0–5.

*— Matches the preceding character zero or as many times as possible. test\d* will match the string test followed by as many digits as it can, or none if no digits are available.

+— Matches the preceding character at least once. test\d+ will match the string test followed by at least one digit.

?— Matches the preceding character at most once. ca?t will match cat and ct.

{x}— Matches the preceding character a specific number of times. The initial phone number pattern we looked at, \d{3} -\d{3} -\d{4}, uses this construct.

{x,y}— Forces a match of at least x repetitions, but no more than y. \d{5,10} will match between 5 and 10 digits.

^— Matches the beginning of a line. ^Line 1 will match the string Line 1 only if it occurs at the start of a line.

$— Matches the end of a line. Line 1$ will match the string Line 1 only if it occurs at the end of a line.

\b— Matches the border of a word. \bpaste will match the word paste but not the word toothpaste. Likewise, \B is the inverse and will match a position that isn't a word boundary.

By constructing searches using regular expressions, you can efficiently find patterns that match multiple items in a single pass. This is far more efficient than having to deal with conducting multiple searches for similar items.


If you define a particularly complicated search pattern, you might not want to have to type it over again the next time you use it. To save your query, click the disk icon in the Find/Replace window. Saved queries can then be reloaded by clicking the folder icon.

Searches can be performed at any time, regardless of whether you are in the HTML source view. Be aware that you cannot run a Search and Replace on files that aren't open. You should always make a copy of your site before performing a potentially destructive search and replace.


Although staying within a single program for editing purposes is nice, sometimes the advanced features of other text editors can come in handy. Dreamweaver MX can launch your favorite text editor by choosing the Edit with option from the Edit menu. You can set the preferred editor within the File Types/Editors Preference category.

Tag Inspector

Another way to look at an overview of the HTML in your document as it is created through the Tag Inspector panel. This tool, shown in Figure 3.27, displays the documents HTML as a hierarchical list of basic tags.

Figure 3.27. The Tag Inspector presents a hierarchical view of the document's HTML.

The Tag Inspector does not show all the document at once, or all the attributes for every tag. In order reveal more information, you must expand the tags that contain the objects you want to see. For example, the <body> tag contains everything in the design view—expanding it will display the objects (tables, images, and so on) you've added to your document. To view the attributes that have been set for a particular tag, highlight the tag in the Tag Inspector and the attributes will appear in the lower part of the panel. You can even edit the values for the attributes by double-clicking the fields beside their names, or by selecting a tag and clicking the Edit icon in the lower-right corner of the panel.

Tag Library Editor

The Tag Library Editor is invoked by clicking the middle icon at the lower-right corner of the Tag Inspector. This tool is probably best left as-is for beginners. It allows you to browse the tags that Dreamweaver MX supports, expand the tags, and edit the individual attributes that the program recognizes. Tag libraries are available for HTML and all the supported development languages. The Tag Library Editor is displayed in Figure 3.28.

Figure 3.28. The Tag Library Editor can be used to edit the very tags that Dreamweaver MX recognizes.

Tag Chooser

A more appropriate way to view and insert tags (rather than digging through the Library Editor) is to use the Tag Chooser—accessible by choosing Tag from the Insert menu. The Tag Chooser, shown in Figure 3.29, divides tags into functional groups, such as Lists, Tables, and so on, and allows you to easily find the HTML you want to use, and then insert it into the document.

Figure 3.29. The Tag Chooser allows you to browse the available tag libraries.

Drill down through the different tag libraries, groups, and so on, to reach the individual tags, which will be displayed in the right pane of the panel. Highlighting one of the available tags and clicking Insert will add it to your document.

To see more information about a selected tag, click the Tag Info button to see the usage information for the highlighted tag. Alternatively, using the <?> button will open the reference information for the tag.

As you can see, Dreamweaver MX offers a number of ways to view your HTML, insert tags directly, and explore the available attributes for modifying each tag.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint