How to Add a DOCTYPE in Dreamweaver

If you’re a Dreamweaver user, you almost don’t have to think about the document type definition (DTD) when creating a web page because the program automatically inserts the selected DOCTYPE and DTD into the code each time you create a new document through the New Document dialog box.

Of course, you have other ways to create a new file in Dreamweaver, and in those cases, the program’s default DTD, as specified in the program’s preferences, will be automatically inserted.

No matter which DTD you select, Dreamweaver automatically writes the appropriate DTD-specific code. For example, if you choose to build pages using the XHTML 1.0 transitional DTD, Dreamweaver’s code editor automatically writes XHTML-compliant code. Likewise, when you choose HTML5, Dreamweaver writes HTML5-compliant code.

To select the appropriate DTD for your new documents in Dreamweaver, follow these steps:

1

Launch Dreamweaver and choose File→New to open the New Document dialog box and select the Blank Page option from the top-left column.

2

Select the HTML option from the Page Type Category, and choose <none> from the Layout column.

Dreamweaver opens a new blank HTML file.

3

In the DocType area in the lower-right corner of the dialog box, use the menu to select the desired document type (DTD).

Over the years, the default in the DocType area has changed from version to version in Dreamweaver. For a long time it was set to HTML 4.01 Transitional before Adobe switched it to XHTML 1.0 Transitional. At the time of this writing, the DocType area may be set to HTML5.

The options in this list are None, HTML 4.01 Transitional, HTML 4.01 Strict, XHTML 1.0 Transitional, XHTML 1.0 Strict, HTML5, XHTML 1.1, and XHTML Mobile.

To modify the default DTD in your copy of Dreamweaver, open the Preferences dialog box by choosing Edit→Preferences (Windows) or Dreamweaver→Preferences (Mac), click the New Document category, and choose the desired Default Document Type from the DTD menu.

4

Click the Create button to open the new, blank HTML or XHTML page in the Dreamweaver workspace.

If you check the code in Code view, you can see the selected DTD at the top of the page, above the opening HTML tag.

Older versions of Dreamweaver, including MX and earlier, either didn’t provide an option to select the DTD or coded in only part of it automatically. If you’re still using an old version of Dreamweaver or another code editor that doesn’t include the DTD, be sure to hand-code the appropriate DTD into your pages or upgrade your software so that your program does it for you automatically.

blog comments powered by Disqus
Advertisement

Inside Dummies.com