Why Transitional Doctypes are Better for WordPress Blogs

Nick Stamoulis

background image

There are many articles and resources out there that preach about XHTML versus HTML and various DOCTYPEs and their uses (a list to a couple of those articles is at the bottom of this post). But regardless of the reasons and arguments for either side, it is very clear that transitional DOCTYPES are better than strict ones for WordPress blogs.

Strict DOCTYPEs areโ€ฆwell, too strict. They don’t allow for certain (necessary) tags to remain in your WordPress blog. Tags such as <strike> are used by WordPress to drop a line through text. Using a Strict DOCTYPE with this is impossible; you will receive an error. Time and time again I see this while reviewing WordPress themes and plugins. It doesn’t need to happen.

Changing Your Doctype in WordPress

Under the Presentation tab click on Header. Find the following selection of code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

It should be at the top of your Header file. If you have a different setup or different theme file setup that makes it tough to find this section of code, leave a comment and I’ll see what I can do to help.

This is the code you do not want to use:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

This is the code you DO want to use:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The xmlns and the language_attributes tags can stay where they are.

Articles for more information:

  • http://alistapart.com/stories/doctype/
  • http://www.w3.org/QA/2002/04/valid-dtd-list.html
  • http://24ways.org/2005/transitional-vs-strict-markup

Browse all articles on the Blog Design category

19 Responses to “Why Transitional Doctypes are Better for WordPress Blogs”

  • Filipino Entrepreneur

    I was wondering if having a wordpress theme xhtml 1.0 compliant will have anything to do with the blog’s performance on the SERP?

  • Mubera

    I think that transitional is still OK to be used. Most websites are using it for various reasons. However, I noticed that some of the themes do not have DTD in header or for that matter nowhere in template files. I wonder, where are those declarations stored because they show in view source.

  • John

    Thank you for your information.Good information!

  • John

    Thank you for your information.

  • Bang Kritikus

    Thanks for your information

  • Bob

    Evidently forums on this site are not moderated.

  • BryanG

    The thread on this post seems to have went dead awhile back but I just ran into it. Sure transitional doc types are fine that is why the W3c offers them as a validation option but I think you should seriously consider why you are using them. It seems to me that W3c offers transitional doc types for situations were you maybe “forced” to use certain types of mark ups because W3c understands not all browsers (especially for backwards compliance) support all CSS mark up. If you are using Transitional as a crutch than shame on you(Sorry). I just put on article on my blog about the importance of validating strict in terms of accessibility issues. Citing a lawsuit against Target in California regarding areas of their site that are not accessible. The day is coming were business will have to guarantee access to users with physical limitations. The best way to prepare for this is to make sure you use valid code.

    Full disclosure though my blog was built awhile ago and is transitional but when I re-design early next year I will use the strict doc type.

  • Michael Wales

    Here’s another quote from the W3C, direct from the DTD about 5 lines below your quotes:

    “Authors should use the Strict DTD unless they need the presentation control for user agents that don’t (adequately) support style sheets.”

    How many bloggers actually have people viewing their page on clients without CSS support?

  • Daniel

    Even if the average WordPress user “does not care” for validation I think we still should, and designers should as well.

    That said, using a Transitional doctype, as I mentioned, does not seem to be “not caring” for proper validation. It is just another DOCTYPE, supported by the W3C, which suits better WordPress.

  • Ryan Imel

    There are those who don’t care about validation and those who care a lot. There are also those in between. But for the general WordPress user, as far as I’ve seen, they tend to be on the don’t-care side of the spectrum.

    In other words, when creating themes for average users to make, Transitional may be the best way to go. It gives them more flexibility, and allows for certain things which WordPress doesn’t (at the moment) care to update.

  • Daniel

    Here is a quote from the W3C:

    “This is the HTML 4.01 Transitional DTD, which includes presentation attributes and elements that W3C expects to phase out as support for style sheets matures.

    Authors should use the Strict DTD when possible, but may use the Transitional DTD when support for presentation attribute and elements is required.”

    Looks like the transitional doctypes are supported then, it is not lazyness from designers, but rather a choice for particular situations.

  • Arpit Jacob

    wow I was a bit amused reading this post. I am a regular reader. I think Michael has already said what I wanted to say. ๐Ÿ™‚ I use a Strict doctype yet my pages vaildate. This has nothing to do with wordpress but its they way you code. Making your website validate while maintaining a strict doctype is hard therefore people take the easy way out

  • Katy

    I have to admit I’ve not actually used WordPress, but I can see where both sides of the argument lie.

    I have written my own blog software and initially added a strict doctype to the template which was fine with content that I generated however if you start to embed things like YouTube videos, Google Adsense or Amazon affliliate code the whole thing fails validation so whats the point?

    Why should I generate “perfect” code when no-one else can be bothered?! ๐Ÿ˜‰

  • Michael Wales

    Just wanted to clarify though: yes, I think WP should update and get with the times. There is a lot more WP could do on the backend processing (and the frontend, if those buttons do use outdated tags) to help the user out.

  • Michael Wales

    Heh – when writing the comment I almost thought of hitting my WP control panel and seeing what those buttons did. I must admit, I’ve never used them ๐Ÿ™

    In reality, I don’t think it matters much. For those people that do use the WordPress buttons they’re probably not worried about validation all that much. WordPress, and those that blog, have a keen knack for destroying validation as soon as a post is made.

    For those that still use the buttons, but know what validation is, they are probably just like the rest of us and are hell-bent on learning everything all the time. Go out and learn more about XHTML/CSS and rewrite your posts and stylesheets in the frame of mind that you will validate and produce good semantic code.

  • Daniel

    Thanks for the link Michael, it was mentioned on the article actually, but the URL was wrong.

    I am no professional designer, but apparently even high profile designers are using the Transitional DOCTYPE, i.e., Chris Pearson.

    I guess they could be forced to do so due to the WordPress structure.

  • Ryan Imel

    I see your point Michael. I would still advocate a transitional DOCTYPE, though, since the use of WordPress’s default “strikethrough” button inserts the strike tag. In order to validate, it seems we should be using a transitional DOCTYPE for this.

    And thanks for the link. I’ll check that out.

  • Leftblank

    I’m with Michael, the problem isn’t with the designers, it’s with WordPress as it’s still using outdated chunks of code.

    Using the latest (and semantically correct) doctype is like updating your WordPress blog to the latest version, perhaps you don’t quite see the use yet, but there are improvements under the hood.

  • Michael Wales

    The transitional DOCTYPE is supposed to be transitional – it was created so sites would still validate as they transitioned over to the strict DOCTYPE. By continuing to use the transitional DOCTYPE you promote a refusal of XHTML/CSS based design.

    The strike tag you refer to is outdated, as it refers to the appearance of the text within the tag. The correct tag that should be used is del which refers to what the tag is accomplishing (it signifies deleted text, via the strikethrough, unless otherwise styled).

    See 24ways for a discussion about Transitional vs. Strict doctype.

Comments are closed.