Home > Articles

This chapter is from the book

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.

NOTE

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.

TIP

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.

NOTE

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.

Actions

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.

TIP

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.

NOTE

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.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020