Home > Articles > Web Development > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Working with a Web Page in Code View

So far you’ve learned how to build web pages in Design view. The Design view, supported by the design window, Properties Inspector, Insert bar, and supporting panels make Dreamweaver an attractive editor for visual developers hoping to create quick web pages without having to know markup or the sometimes confusing coding languages such as CSS and JavaScript. Although working in Design view may certainly be a positive for most developers, it’s important to highlight some of the supported coding features that truly make Dreamweaver one of a kind. The last part of this chapter hopes to unleash the unique coding aspects that some people come to expect from the industry-leading web-page-development environment.

Code Hints

We’ve looked at some of the visual preferences (such as line numbers, word wrap, and syntax coloring) in Code view, we’ve yet to outline and detail some of the powerful features that can aid you in development regardless of view. Arguably one of the most useful features in Code view is that of code hints. Those who made a living developing with HomeSite in the late 1990s certainly remember this feature because it was integral part of the HomeSite development environment and a huge reason HomeSite’s popularity was unmatched. Thanks to the Macromedia/Allaire merger, Dreamweaver gained from the popularity that code hints had in HomeSite. Using code hints in the Code view environment is easy; understanding how it works is to understand the underlying structure behind HTML/XHTML. HTML/XHTML is an authoring language, not a programming language. The developer is entirely responsible for creating the structure that she wants her users to see using a markup language like HTML/XHTML. Organized using a well-formed structure of tags in conjunction with attributes, the browser parses the tags and presents to the user the structure that the developer intended. For future reference, Figure 3.51 outlines the structure of a typical HTML/XHTML tag.

Figure 3.51

Figure 3.51 HTML tags contain attributes, attribute values, and generally wrap literal text or in some cases, other HTML elements such as images.

The more intricate the structure and inclusion of tags and attributes, the more detailed the design can look within the browser. As an HTML/XHTML developer, you’ll quickly realize that there are hundreds of HTML/XHTML tags, with each tag having dozens of attribute combinations. As a developer, it’s extremely difficult to remember them all. Fortunately, Dreamweaver’s code hints automate what we may want to add. Accessing code hints is as simple as switching to Code view in a new HTML page, placing your cursor in the <body> tag, and typing. For instance, if I type the < symbol (this symbol represents the beginning of an HTML tag), the code hints menu appears complete with every supported HTML tag (see Figure 3.52).

I can use the keyboard up and down arrow keys to cycle through the tags in the code hints menu. When I’ve found the tag I want to use, I press Enter to add it to the code. Pressing the spacebar opens the code hints menu again, but this time only the attributes for the selected tag appear (see Figure 3.53). (You could also just continue typing, and Dreamweaver auto searches and updates the code hints menu with the most appropriate tag based the letters you have entered.) When your tag is highlighted, press Enter.

Figure 3.52

Figure 3.52 The code hints menu appears complete with all possible HTML tags.

Figure 3.53

Figure 3.53 All attributes for a selected tag appear in the code hints menu.

Again, pressing Enter adds the selected attribute. Depending on the attribute you add, the code hints becomes more detailed. In my case, I choose the href attribute (creates the reference for the hyperlink) of the <a> (tag used for creating links) tag. The Browse code hint then appeared, allowing me to choose a file. After I add my file, I can use the right-arrow key to move to the next attribute and press the spacebar to repeat the process. When I finish formatting the tag, I need only add the > symbol to close out the opening tag. Finally, I’ll add the < symbol to begin the closing tag followed by the / symbol, in which case the closing tag is added automatically for me by Dreamweaver.

As I mentioned earlier, the more intricate the structure of your HTML/XHTML, the better your designs will look...the possibilities are limited only by your needs.

The Code View Toolbar

For developers used to working with code in HomeSite, the Code View toolbar docked to the left side of the coding environment and shown in Figure 3.54should look relatively familiar.

Figure 3.54

Figure 3.54 The Code View toolbar provides quick access to commonly used commands for the Code view user.

The Code View toolbar provides quick access to commonly used commands for the Code view user, specifically:

  • Open Documents: Click and hold this icon in the toolbar to display all currently open documents. Then choose a document from the list to focus the document in Code view.

  • Collapse Full Tag: You can place your cursor onto an opening tag and then click this button to collapse the tag and everything within it. This button is discussed in more detail in the next section.

  • Collapse Selection: You can highlight a section of code and then click this button to collapse the selection. This button is discussed in more detail in the next section.

  • Expand All: Expands all collapsed code.

  • Select Parent Tag: Selects the parent tag within the hierarchy based on your cursor position in the code. For example, if you’re within the <td> tag of a table, selecting this option selects the <table> tag because the <table> tag is the parent for both the <tr> and <td> tags.

  • Balance Braces: When working with client-side scripting languages such as JavaScript, click this button to highlight all code within the braces of a function.

  • Line Numbers: Displays or hides line numbers.

  • Highlight Invalid Code: Similar to the Highlight Invalid Code option (located in the View options menu in the Document bar), choose this option to enable or disable the highlighting of code that is considered invalid to a browser.

  • Apply/Remove Comment: Choose the Apply Comment button to open the comment selection menu similar to Figure 3.55. It’s from this menu that you have the option of inserting a HTML, CSS, JavaScript, or VB.NET, comment. Alternatively, you can click the Remove Comment button to delete an existing comment from the code view.

  • Figure 3.55

    Figure 3.55 Choose a comment type from the comment selection menu.

  • Wrap Tag: Highlighting an element in code and selecting this button opens the Wrap Tag dialog. It from this dialog that you can enter an element that should wrap the selection. You’ll notice that code hints also work within the Wrap Tag dialog.

  • Recent Snippets: Selecting this button opens the recent snippets menu. From this menu, you can pick from a list of recently added snippets or even launch the Snippets panel to choose from Dreamweaver’s library of snippets.

  • Indent/Outdent Code: Choose from these two buttons to indent or outdent code.

  • Format Source Code: Also available from the Commands menu, you can click and hold this option to apply the default Dreamweaver code formatting to either the entire page of code or to selected blocks of code. Alternatively, you can choose the Code Format Settings option to launch the Preferences dialog with the Code Format option preselected. More information about Preferences is provided in Chapter 5, "Defining Preferences."

Of course, you can also show and hide the Code View toolbar by right-clicking the toolbar and checking/unchecking the Coding option from the context menu.

Code Collapse

Code collapsing provides the developer with the ability to highlight a segment of code and collapse it so that it’s temporarily hidden from view. The obvious benefit to this is increased screen real-estate. To use the code collapse feature, follow these steps:

  1. With the companydirectory.htm page open, switch to Code view if it’s not already selected.

  2. Highlight a section of code. Notice the line segments that appear in the line numbers column similar to Figure 3.56.

  3. Figure 3.56

    Figure 3.56 Line segments appear in the line numbers column, indicating the segment of code that can be collapsed.

  4. Choose one of the segment icons to collapse the code similar to Figure 3.57. Alternatively, you can choose the Collapse Selection button from the Code View toolbar. Notice the small plus (+) icon that appears next to the collapsed code.

  5. You can expand the code by choosing the plus (+) icon that appears next to the collapsed code. Alternatively, choose the Expand All button in the Code View toolbar to expand all collapsed code.

Figure 3.57

Figure 3.57 The code is collapsed and temporarily hidden from view.

The Tag Inspector

After you’ve created the tag structure, you can use the Tag Inspector to format all attributes of a tag through a visual panel. Part of the Tag panel group and available by choosing Tag Inspector from the Window menu, the Tag Inspector visually categorizes and lists all attributes supported by a tag. As you can see in Figure 3.58, the Tag Inspector displays all attributes and attribute values for the selected tag.

Figure 3.58

Figure 3.58 The Tag Inspector visually displays attributes and attribute values for a selected tag.

Depending on the attribute value you select, the Tag Inspector either allows you to manually type a value or allows you to select from a list of values through a menu similar to Figure 3.59.

Figure 3.59

Figure 3.59 Enter attribute values or select from a list of attribute values in some cases.

Although the Tag Inspector works in both Code and Design views, its inclusion and subsequent benefits are immediately obvious.

Using the Tag Chooser

The next major addition to the development interface is the Tag Chooser. The Tag Chooser, available by selecting the Tag option from the Insert menu, is a collection of HTML, CFML, ASP.NET, JSP, JRun, ASP, PHP, WML, and XSLT tags. To use this intuitive window, place your cursor in the <body> tag and choose Tag from the Insert menu. The Tag Chooser dialog appears similar to Figure 3.60.

Figure 3.60

Figure 3.60 The Tag Chooser contains a complete collection of HTML, CFML, ASP.NET, JSP, JRun, ASP, PHP, and WML tags.

Choose the tag collection you’d like to explore; the tags are further organized within structural categories. For instance, the <a> tag is organized in the General option of the Page Elements category. Choosing the <a> tag from the elements pane also reveals the HTML reference for the <a> tag within the More Info pane similar to Figure 3.61.

Figure 3.61

Figure 3.61 HTML tags are organized in categories. Selecting a tag opens the reference for the tag in the More Info pane.

To insert a selected tag, simply choose the tag and click Insert to launch the Tag Editor dialog (see Figure 3.62).

Figure 3.62

Figure 3.62 The Tag Editor dialog allows you to format properties for a specific tag.

After you’ve formatted the attributes of the tag, click OK to insert the tag into the coding environment. You can either continue adding tags using the Tag Chooser or click Close to return to the coding environment.

Working with Snippets

The final development aid you can use in the Code view is snippets. Snippets are a clever way to save small blocks of prewritten code so that they are always available to you (and other developers) for use. Available from the Code panel group, the Snippets panel is structured as a series of folders into which snippets are organized. Each folder covers a particular technology or area of functionality. As you can see from Figure 3.63, Dreamweaver includes numerous code snippets you can use.

Figure 3.63

Figure 3.63 Code snippets are organized into folders specific to the respective technology. Dreamweaver includes prebuilt snippets you can use.

Notice that the Snippets panel is organized into two halves. The top half includes a preview of the code snippet selected from the categorized list of snippets in the bottom half. HTML snippets are usually shown in Design view (showing what the HTML looks like in the browser), whereas JavaScript and other code snippets are shown in Code view (so that you can see the actual code). Inserting a snippet is merely a matter of selecting the appropriate snippet and either dragging it into the code environment or clicking the Insert button located in the bottom left of the Snippets panel.

Creating your own snippet is just as easy but slightly more involved. To create your own snippet, follow these steps:

  1. Create a new folder for your snippet by right-clicking in the Snippets window and choosing New Folder. Give the snippet folder a descriptive name, remembering that other developers might want to use these snippets, too. If the folder is created in the "wrong" place, you can drag it to the level you want. I’ll call my new folder Table Row Rollover.

  2. Right-click the folder and choose New Snippet from the context menu. If you have already written the snippet code in the page, highlight the code you want to use as the snippet, right-click the highlighted code, and choose Create New Snippet from the context menu.

  3. You are presented with the Snippet dialog. Fill in the snippet name and description. If you have highlighted existing code, the code box is already filled in. I’ll add the following HTML code to the Insert Before text box:

  4. <table>
    <tr onmouseover="this.style.backgroundColor=’#cccccc’;" 
    onmouseout="this.style.backgroundColor=’#ffffff’;">
    <td align="center" width="125"><a href="#">Home</a></td>
    </tr>
    <tr onmouseover="this.style.backgroundColor=’#cccccc’;" 
    onmouseout="this.style.backgroundColor=’#ffffff’;">
    <td align="center" width="125"><a href="#">HelpDesk</a></td>
    </tr>
    <tr onmouseover="this.style.backgroundColor=’#cccccc’;" 
    onmouseout="this.style.backgroundColor=’#ffffff’;">
    <td align="center" width="125"><a href="#">Company Directory</a></td>
    </tr>
    <tr onmouseover="this.style.backgroundColor=’#cccccc’;" 
    onmouseout="this.style.backgroundColor=’#ffffff’;">
    <td align="center" width="125"><a href="#">Employee Store</a></td>
    </tr>
    <tr onmouseover="this.style.backgroundColor=’#cccccc’;" 
    onmouseout="this.style.backgroundColor=’#ffffff’;">
    <td align="center" width="125"><a href="#">Admin</a></td>
    </tr>
    </table>
  5. This code effectively creates a new table, complete with rows; when the user’s mouse rolls over the rows, the background color changes to a gray color.

  6. If you want the code to flow around a selected object, such as an image or table cell, select the Wrap Selection option, specifying which part of the code goes before the object and which after the object. If the code is a standalone block, choose the Insert Block option. I’ll choose Insert Block. The completed Snippet dialog should resemble Figure 3.64.

  7. Figure 3.64

    Figure 3.64 Create the new snippet in the Snippet dialog.

  8. When you finish editing the Snippet dialog, click OK. The new snippet appears in its folder and the preview pane will display the HTML.

To use the snippet, simply drag the snippet into the code environment and choose Preview In Browser (or press F12) to test the results.

Editing, moving, and deleting snippets are also a snap. To edit a snippet, right-click the snippet and choose Edit from the context menu. The Snippet dialog appears, and you can edit the code or change the description. To move snippets into other folders, drag them to the folder you want. To delete a snippet or its respective folder, right-click the snippet (or folder) and press the Delete key.

  • + Share This
  • 🔖 Save To Your Account

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