You are currently browsing the page Doctypes in the HTML category.

Doctypes

In order to validate your page, the first thing to do is to choose a doctype. Using valid codes is pointless without the two lines which compose the document type declaration. Besides, using valid codes without or with a wrong doctype can cause the page to show up uncorrectly. (I have already experienced that.)

I will only list HTML 4.01 and XHTML 1.0 doctypes since they're the most commonly used ones. There are 3 types for each: Strict, Transitional or Frameset.

  • HTML 4.01 Strict: you can't use deprecated elements, nor target attributes in links nor frames.
  • HTML 4.01 Transitional: you can use any deprecated elements and have links targets, but if you have frames, use the next doctype.
  • HTML 4.01 Frameset: it is the same as Transitional but it's a doctype for pages using frames.

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

It is the same for XHTML 1.0 Strict, Transitional and Frameset.

  • XHTML 1.0 Strict: you can't use deprecated elements, nor links targets nor frames.
  • XHTML 1.0 Transitional: you can use any XHTML 1.0 code, but no frameset.
  • XHTML 1.0 Frameset: it is the same as Transitional but it's a doctype for pages using frames.

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

Of course, you have to use valid HTML 4.01 or XHTML 1.0 and code properly. Now you can choose the best doctype for you and paste it in your codes. It must be placed at the very top, before the html attribute.

Print This Post Print This Post



Sponsors


Leave a Comment

Works? Doesn't work? Other tips? Please leave a comment! :)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

To post codes, please go to SimpleCode and transform your codes first, so that it will displayed properly. Indeed, < and > need to be converted to &lt; and &gt; :)


Close
E-mail It