Doctype Made Easy

When you create a new page in Dreamweaver, the first line of code usually looks something like this:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
Ever wondered what that means? Understanding the docctype statement, as that line is called, requires a very, very brief history lesson. Don’t worry, I’ll make it brief.
HTML started with a very basic list of tags (and rules on how to use them) back in 1989. Over the years, more tags were added (and some removed), so HTML came out with version 2, version 3, version 3.2, version 4, and finally 4.1. XHTML was then developed. (To make it even more confusing, we have different versions of HTML 4.1 and XHTML — a “strict” version that has very strict rules, a “transitional” version that is a little more loose, and a “frames” version for sites that use frames.)
(Wasn’t that brief?)
These different versions of HTML and XHTML have slightly different rules for how — and which — HTML tags can be used in a document and how to format them. Just to give you a quick example, XHTML has stricter rules than HTML — the tags have to be lowercase and certain tags (<u> for underlining) can’t be used at all. In HTML, tags like <br> and <link> now require a “closing slash” in XHTML, so they must be written like <br /> and <link />.
So for optimized viewing of the site, the browser should be able to tell what version of HTML/XHTML you’re using. That’s when the doctype statement comes in. Compare these different doctype statements below:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
The doctype tag contains the information about which DTD, or document type definition, is being used, and contains a web address that links to the full explanation of that language.
Now, what’s great about Dreamweaver (which was the point of this blog) is that you don’t have to worry about keeping track of which tags you can or can’t use and how your code should be formatted. As soon as you set the doctype of your web site, Dreamweaver handles the code for you automatically. Even if you are used to hand-coding an <img> or a <br> tag in the old-school HTML way, if your doctype is set to XHTML, Dreamweaver automatically adds the closing slash for you.
You can change the docctype by typing Ctrl-J (Command-J for Macs) to access the page properties, then going to TItle/Encoding and changing the Document Type. (You can also right-click on the page itself and choose Page Properties.) Once you do that, Dreamweaver formats your code accordingly!

Leave a Comment

Your email address will not be published. Required fields are marked *

Enter Code *

Filed Under

Related

Do you need to build a custom search-driven component for your #digitalworkspace while saving thousands of hours of development time?

Join us on as we lift the hood of #PnP Modern Search v4, show you how it's built, & take you on a live coding adventure.

http://ow.ly/MTnL50EpN5J

#Hybridwork is more than just a buzzword to latch onto; it’s the future for many organizations for the unforeseeable future. So, how can you use #Microsoft365 for #hybridwork? Let's breaks it down…

http://ow.ly/ay2e50EmNhg

It's that time again! Join the #PixelMillWebinars on 4/29 where @EricOverfield lifts the hood of #PnP Modern Search v4, shows how it's built, & takes you on a live coding adventure to customizing your own web part using the power of the existing codebase.

http://ow.ly/EI5h50EmNqj

What? Anchor links now work in #SharePoint site navigation! This fix snuck in and I completely missed it. Use them to create a TOC for long pages or cross link between pages. They work in text or quick links web parts & nav too! https://support.microsoft.com/en-us/office/create-and-use-modern-pages-on-a-sharepoint-site-b3d46deb-27a6-4b1e-87b8-df851e503dec#bkmk_pageanchors

A big thank you to David Leveille and @CrushNetworks for having our President + Co-Founder @EricOverfield on this episode of #TheVirtualWaterCooler!

Subscribe to PixelMill's
E-news

* indicates required

Let's Talk Digital
Workspaces Today

Get In Touch