As much as I love the open web, it’s almost too easy to get work done without really understanding what it is that you’re actually doing.
For example, I’d bet that many of us – at some point or another – have taken a code snippet off of another site, plugged it into our own work, and then used it. On one hand, there’s nothing wrong with that. We even promote it. But I think that spending a little bit of extra time to truly make sense of what you’re doing is where getting into real development begins.
Once you understand what it is that you’re doing and how it works, you can stop relying on code elsewhere around the web and begin creating things on your own (or that other people could end up borrowing).
All of this holds true for platforms, environments, languages, and systems. It also holds true for other pieces of code that are seemingly more trivial such as a page’s DOCTYPE.
Let’s take a look.
DOCTYPE Defined
If you’ve ever viewed the source of a [well-written] page, then you’ve likely seen this declaration at the very top of the document:
Yes, there are variations in exactly what is contained in the DOCTYPE, but that’s the general format.
The DOCTYPE is how to tell the browser what variation of markup you’re going to be using. Simply put, you’re giving the browser a heads up on what to expect when it begins processing your content.
But what does it mean?
There are actually four parts to the DOCTYPE declaration:
- DOCTYPE tells the browser that the following information defines the standards used to create the page.
- HTML informs the browser what element to expect as the very first element in the document.
- PUBLIC specifies that the DOCTYPE being used is publicly available. There are other terms (such as SYSTEM) but you’re most commonly going to use PUBLIC.
- “-//W3C//DTD XHTML 1.0 Transitional//EN” is an example of the actual document type that’s being used. W3C refers to the organization maintaining the DOCTYPE, the DTD (or the document type definition) is the standard by which the markup is written, XHTML 1.0 Transitional is the actual document type definition being used, and EN is the language of the DOCTYPE.
Obviously, anyone can create a document type that other pages can reference and there are a variety of them already available though you’re likely to most often find only a few types commonly used.
I know – understanding DOCTYPE isn’t going to help build the next great application but it will make it easier to understand the significance of what you’re doing whenever you begin developing your next site (or borrowing someone else’s code).
Over time, we can take a look at some other technologies. Remember that guest articles are always appreciated ;).
Kyle Reed says
and now I know. Keep them coming, love post like this