What DOCTYPE! to use for my site

I am somewhat confused with what DTD declaration/!DOCTYPE to use on my site. Currently I have none and it appears to view just fine on Firefox, Chrome, and IE but everything I am reading says you need to have one. Is there a general rule of thumb that you use in determining what DTD to use?

I located this source of info but I wasn’t sure if my site is considered HTML or XHTML so I didn’t know what to go with. How to I determine this?

If your document is HTML, use this:

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd”>

If your document is XHTML, use this:

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

If you don’t know we, cannot know either… what did you write XHTML or HTML markup? Without seeing a page example or a live page we have no way of being able to tell you either way.

You need to specify a doctype on each page otherwise at least IE will go into quirks mode.

You really should use a STRICT doctype for either html or xhtml. There is no justification for using a TRANSITIONAL doctype for new or recent websites.

If you can’t or won’t post your code or a link to it, you can put both doctypes (one at a time) on a page and see which page has fewer errors on the W3C validator. Then fix the code in the page for that doctype until all the errors are gone.


<!DOCTYPE html>

Beautifully simple isn’t it?

Except that if the page doesn’t have any html5 specific elements, then the html5 doctype declaration is really meaningless and causes markup validation issues. html5 is by no means finalised and will be in development for at least a few more years and even the w3c validator says its html5 validation results should not be relied upon :slight_smile:

Go with the HTML4 Doctype for that. Font tags? Not good. Keep XHTML off it.

Regarding your SEO:

  • The title tag is way to long. Search engines will see through the keyword stuffing (probably) and browsers won’t display that much text. Doesn’t read well for users anyway.
  • Meta keywords are ignored.
  • Meta description is too long. I hear a max of 160 chars thrown around often.

…having said that one thing HTML5 does do is specify (in the spec) how browsers should handle invalid markup (proper errors such as incorrectly nested tags).
Previously it was up to individual browsers to decide how to construct the DOM from bad markup. If you’re at risk of these errors HTML5 is probably the better choice.

since you did not close your IMG and BR tags, it’s not xhtml

therefore, you should be using this doctype –

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

I didn’t create the site. I am just trying to maintain it correctly.

Thanks r937

This is the result of using the code you suggested. As you can see, it creates white gaps between items.

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd”>


cranial-bore

I also shortened the Title Tag and Meta Description.

I am not sure what you mean by “Meta keywords are ignored.” can you expand please?

This one seemed to do the trick.
I tested it on FireFox, IE9, and Chrome.

<!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”>

That doctype is for web sites created bac k in the 20th Century that haven’t yet finished getting rid of the HTML 3.2 tags. You shouldn’t use it for new sites.

If using a strict doctype displays the page incorrectly then you have not coded the CSS the right way to get what you want.

You should fix the CSS to correct the way the page displays rather than moving back into the 20th Century with an old doctype.

What I meant about the meta keywords is that search engines do not consider them at all when ranking a site, or determining the page content. They are very easily faked because users never see them, so have had zero weight on search results.

You can drop them and save a little bit of page size.

Unless you decide to implement a script on your own site that uses them. If you do that then the meta keywords tag will be used because you are using it yourself.

Unless you implement something yourself that uses it though it is a complete waste of space being there as too many sites abused its intended use with search engines in the past and so the search engines now all ignore it completely.

Thanks felgall. I was afraid of that. I am a newbie to CSS so I will have to try to figure it out.

Will do!

Thank you.

<!DOCTYPE html>

It’s not really a specifically HTML5 doctype, though, but a doctype that can be used with any version of HTML. And it’s nice and simple. I don’t see any reason not to use it.

ah, ok :slight_smile:

But I based my post on what I read in this post discussing the above doctype

So who is correct - you or deathshadow60? :confused:

I think his point there is that the rules for that new doctype are very forgiving, turning a blind eye to HTML practices that are not allowed in XHTML (such as non-closed elements). But I guess I shouldn’t speak for DS. :slight_smile: