Forum Moderators: open
I've never put a DocType in my HTML pages (actually they are .asp). I just check validator.w3.org/ and found that I need to do that first.
I have checked out several posting here on this topic but they are quite old. There are so so many different doctypes and need to know which to you.
Here are a few they say that are common but I just can't understand all the mambo jumbo. Can someone help me on which is most common and suitable TODAY. I am using HTML and have asp scripts and my page is save as .asp. Please help.
Here are some of the common ones they mention:
1) HTML 4.01 Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2) HTML 4.01 Transitional.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3)HTML 4.01 Frameset.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
The rest are here:http://www.htmlhelp.com/tools/validator/doctype.html
Also if I use the wrong one, will anything happen or will I be penalized? Please help.
That said, the best doctype, IMO, for someone who doesn't know about them is your #2 above, the HTML4.01 Transitional. This is a little more forgiving than the Strict doctype. I suppose if you use framesets, the Frameset one is best. Somewith with more frameset experience would have to chime in on that one.
Again, the most important things about a doctpye is (a) having one, (b) that it is FULL and VALID, and (c) that it is the very first thing in the source code (not even a whitespace before it).
To ensure that you're using a full and valid doctype, cut and paste it directly from this page [w3.org].
cEM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
This should come before the following right?...
<html>
<head>
...
</head>
<body>
Is that it? Thanks.
I did see the example putting this too:
<!ENTITY % HTML.Version "-//W3C//DTD HTML 4.01 Transitional//EN"
-- Typical usage:
Is that needed?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>
<head>
(etc...) Once your pages validate as HTML 4.01 Transitional, you might want to try HTML 4.01 Strict - this will mean you will need to remve deprecated (outdated) presentational markup and use CSS more extensively.
Honestly my HTML coding with ASP scripts may not really follow convention completely. I try to but I definately may be wrong here and there. What should I do?
I am really confuse now. What is strict and what is transitional really? Will I be wrong in using either one? How do I know when to use what?
According to the HTML 4.01 Transitional DTD:
... the HTML 4.01 Transitional DTD, ... 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.
So, if you need support for deprecated presentational elements [w3.org] and attributes [w3.org] then use the Transitional (also called "Loose") DTD.