/    Sign up×
Community /Pin to ProfileBookmark

Which DOCTYPE?

When I start a new page, i copy a doctype declaration from an old existing file.

Is it important to put a proper doctype declaration on each page? if it is, which one we should choose?

to post a comment
CSS

11 Comments(s)

Copy linkTweet thisAlerts:
@scragarApr 01.2008 — http://www.w3.org/QA/2002/04/valid-dtd-list.html

use HTML4.01 strict if you can, if not then transitional is good enough. Frameset is to be used only for frames. true XHTML is broken in IE6, so I'd avoid using XHTML just yet, until it's usage drops.
Copy linkTweet thisAlerts:
@drhowarddrfineApr 02.2008 — Without a doctype, IE goes into quirks mode and doesn't make an attempt to behave like other modern browsers so, yes, it is required.
Copy linkTweet thisAlerts:
@mickliddyApr 02.2008 — What happens if your using elements from 2 doctypes? I have a page that uses CSS to position the objects around the page and one of the elements is an inline frame! :S

Is there a way to declare a second doctype? or what should I do? The W3C HTML validator is telling me that my page is invalid ?
Copy linkTweet thisAlerts:
@FangApr 02.2008 — One doctype. If using [I]iframe[/I] use Transitional<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Copy linkTweet thisAlerts:
@mickliddyApr 02.2008 — K, thanks ?
Copy linkTweet thisAlerts:
@scragarApr 02.2008 — iframes don't validate in anything above frameset(since they count as frames), but since IE6- doesn't support the object tag as it should:
[code=html]<!--[if !IE]>-->
<object data="http://www.site.com/" type="text/html"></object>
<!&#8211;<![endif]&#8211;>
<!--[if gte IE 7]>
<object data="http://www.site.com/" type="text/html"></object>
<![endif]-->
<!--[if lt IE 7]>
<iframe src ="http://www.site.com"></iframe>
<![endif]-->[/code]
Copy linkTweet thisAlerts:
@FangApr 02.2008 — [I]iframe[/I] is valid in Loose (Transitional) DTD: http://www.w3.org/TR/html401/index/elements.html
Copy linkTweet thisAlerts:
@drhowarddrfineApr 04.2008 — Transitional/Loose/Sloppy ?
Copy linkTweet thisAlerts:
@felgallApr 04.2008 — Scragar's code will validate as Strict since the iframe tag is hidden in a conditional comment so only IE6 and earlier will see it and all other browsers will see the object tag (which is the correct way to do it which Microsoft only implemented in IE7).
Copy linkTweet thisAlerts:
@FangApr 04.2008 — Scragar's code will validate as Strict since the iframe tag is hidden in a conditional comment so only IE6 and earlier will see it and all other browsers will see the object tag (which is the correct way to do it which Microsoft only implemented in IE7).[/QUOTE]You are deceiving the validator by hiding the elements. In IE6 a DTD strict and iframe do not validate.

It's like adding a [I]target[/I] attribute using JavaScript to evade true validation.

The first CC is wrong anyway:&lt;!--[if !IE]&gt;&lt;!--&gt; &lt;object data="http://www.site.com/" type="text/html"&gt;&lt;/object&gt; &lt;!--&lt;![endif]--&gt;
Copy linkTweet thisAlerts:
@toicontienApr 04.2008 — A good overview of doctypes: [B]About DOCTYPEs[/B]
×

Success!

Help @mrtblt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...