My site is throwing up a few errors typically due to trailing slashes being added.

eg. wordpress is adding in:

<meta name='robots' content='noindex,nofollow' />

my doctype is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

If my understanding is correct the validator is seeing those trailing slashes as being xhtml but is getting worried as the doc type doesn't state it.

I don't want it to be an xhtml doctype as that causes me lots of other problems.

My code is fine but its bits like that meta tag that wordpress is putting in that is causing the problem. How do I solve this?

the trailing slash is making the validator think things are closing so its then throwing up errors on stupid stuff like my closing head and opening body tags.

1 Answer 1


Use a HTML5 document declaration:

<!Doctype html>

XML self closing slashes are allowed in HTML5.

In an attempt to turn this into a WordPress question (really, it isn’t): WordPress spits out hard coded XHTML style in many places. Since most people will not send real XHTML, HTML5 is the best option to deal with WordPress’ legacy code while keep validating markup.

  • thanks but sadly a decision was made to not make the site html5 for various reasons so I cant really go down that route. surely it is a valid question though as it is wordpress that is generating the slashes that are upsetting the validator. i know it wont actually affect how the site works but it would be nice to get it to validate. many thanks though! Commented Feb 22, 2012 at 12:07
  • 1
    You don’t need any further changes, just the doctype.
    – fuxia
    Commented Feb 22, 2012 at 12:09
  • just tried it out of curiousity and it threw up more errors due to things that it wants tackled in css instead which right now is more work than i have time for. thanks anyway - i suspect i may have to live with the errors until i can do a re-write. Commented Feb 22, 2012 at 12:16
  • I tried creating a pull request in wordpress core. My understanding is that unit tests and linters start failing in wordpress core when the trailing slashes are removed. And since the core team probably want to use those tools, this will probably not be merged until those linters and tests have solved this issue where code seems to be missinterpreted. See github.com/WordPress/wordpress-develop/pull/4947
    – SimbaClaws
    Commented Aug 1, 2023 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.