English 中文(简体)
Shorter way of specifying HTML 4.01 Strict
原标题:
  • 时间:2009-12-11 15:28:01
  •  标签:
  • html
  • doctype

I am using

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

in my web pages.

I remember reading in one of those XHTML vs HTML questions that one of the (small) advantages of using HTML is, a shorter DOCTYPE like

<!DOCTYPE html>

Can I use some shorter version like that and specify HTML 4.01 Strict?

If I simply use the short version, what will it be taken as? - Strict, Transitional?

最佳回答

Nope, if there were a shorter version we would all be using it. :) The short type you are referring to is HTML 5.

问题回答

Nope. I m afraid that s the only way to specify using HTML 4.01 Strict.

Don t think there s a shorter way of specifying a HTML 4.0 Strict Doctype, which is a pretty specific document type. The doctype you gave would be valid for HTML 5, which may well be a good choice for a new site anyway.

You can simply leave of the URL, and use just the public identifier, like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

This will validate as HTML 4.01 Strict, and trigger standards mode. The short DOCTYPE is also valid for HTML 4.01 Transitional, but will trigger quirks mode in some browsers. Keep in mind, though, that this is strictly forbidden in XHTML.

If you want your HTML to be validated you will at least need to specify an (url to) a DTD...

I think you maybe could leave out the public name, maybe be changing the keyword PUBLIC to SYSTEM. But i m not quite sure about this...

EDIT: Why is this voted down?? The question was for HTML 4, not for 5...





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签