placement of DOCTYPE

D

Disco

Hi,

Can someone please tell me (or point me to where I can find out) if the
<!DOCTYPE... "must" be _before_ the <html> tag or may it be after the <head>
tag?

Thanks
 
B

brucie

Can someone please tell me (or point me to where I can find out) if the
<!DOCTYPE... "must" be _before_ the <html> tag or may it be after the <head>
tag?

<quote>
7.1 Introduction to the structure of an HTML document

An HTML 4 document is composed of three parts:
a line containing HTML version information, <-----****
a declarative header section (delimited by the HEAD element),
a body, which contains the document's actual content. The body may be
implemented by the BODY element or the FRAMESET element.

White space (spaces, newlines, tabs, and comments) may appear before
or after each section. Sections 2 and 3 should be delimited by the
HTML element.
</quote> http://www.w3.org/TR/html401/struct/global.html#h-7.1
 
D

Disco

brucie said:
<quote>
7.1 Introduction to the structure of an HTML document

An HTML 4 document is composed of three parts:
a line containing HTML version information, <-----****
a declarative header section (delimited by the HEAD element),
a body, which contains the document's actual content. The body may be
implemented by the BODY element or the FRAMESET element.

White space (spaces, newlines, tabs, and comments) may appear before
or after each section. Sections 2 and 3 should be delimited by the
HTML element.
</quote> http://www.w3.org/TR/html401/struct/global.html#h-7.1

Thanks brucie, I have another question (sorta similar).

I want to know if comments are allowed to be outside of the <html> tags.
IE. Can a comment block (<!-- comment -->) be before the <html> tag. This
link http://www.w3.org/TR/html401/intro/sgmltut.html#idx-HTML says "*Note
that comments are markup*". Because comments are markup, does this suggest
the comment *must* be inside the <html> tags?

Also, this url that you gave in your previous post does not give me a
definative answer to my previous question. It does not say the order, or
the fact the the <HTML> "part" is required. It suggests the following...

<!DOCTYPE ...... etc
<HEAD ....... etc
<BODY .... etc (or <FRAMESET ...... )

it does not suggest this......
<!DOCTYPE ...... etc
<HTML
<HEAD ....... etc
<BODY .... etc (or <FRAMESET ...... )
.......etc

Thanks
 
D

Disco

Disco said:
Thanks brucie, I have another question (sorta similar).

I want to know if comments are allowed to be outside of the <html>
tags. IE. Can a comment block (<!-- comment -->) be before the <html>
tag. This link
http://www.w3.org/TR/html401/intro/sgmltut.html#idx-HTML says "*Note
that comments are markup*". Because comments are markup, does this
suggest the comment *must* be inside the <html> tags?


hang on just a goddamn moment! I'll take the following back........
Also, this url that you gave in your previous post does not give me a
definative answer to my previous question. It does not say the
order, or the fact the the <HTML> "part" is required. It suggests
the following...

<!DOCTYPE ...... etc
<HEAD ....... etc
<BODY .... etc (or <FRAMESET ...... )

it does not suggest this......
<!DOCTYPE ...... etc
<HTML
<HEAD ....... etc
<BODY .... etc (or <FRAMESET ...... )
......etc



Thanks
 
M

Mark Parnell

Disco said:
Thanks brucie, I have another question (sorta similar).

I want to know if comments are allowed to be outside of the <html>
tags. IE. Can a comment block (<!-- comment -->) be before the <html>
tag. This link
http://www.w3.org/TR/html401/intro/sgmltut.html#idx-HTML says "*Note
that comments are markup*". Because comments are markup, does this
suggest the comment *must* be inside the <html> tags?

Well, it validates with comments before the <html> tag. The reference that
brucie quoted above seems to indicate that it isn't valid though. It seems
to indicate that you have the DTD, then *everything* else is within the
<html> element.
<quote>
Sections 2 and 3 should be delimited by the HTML element.
</quote>
It does say *should*, though, rather than *must*.
 
B

brucie

I want to know if comments are allowed to be outside of the <html> tags.

</quote>
White space (spaces, newlines, tabs, *and comments*) may appear before
or after each section.
Also, this url that you gave in your previous post does not give me a
definative answer to my previous question.

<quote>
An HTML 4 document is composed of three parts:
1. a line containing HTML version information,
2. a declarative header section (delimited by the HEAD element),
3. a body, which contains the document's actual content.
It does not say the order,

<quote>
1. a line containing HTML version information,
2. a declarative header section (delimited by the HEAD element),
3. a body, which contains the document's actual content.
or the fact the the <HTML> "part" is required.

<quote>
Sections 2 and 3 should be delimited by the HTML element.
</quote> http://www.w3.org/TR/html401/struct/global.html#h-7.1

<quote>
SHOULD This word, or the adjective "RECOMMENDED", mean that there
may exist valid reasons in particular circumstances to ignore a
particular item, but the full implications must be understood and
carefully weighed before choosing a different course.
</quote> http://www.ietf.org/rfc/rfc2119.txt

<quote>
<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->
^^^^^^ opening and closing tags optional
</quote> http://www.w3.org/TR/html401/struct/global.html#edef-HEAD
 
M

Mark Parnell

Mark said:
Well, it validates with comments before the <html> tag. The
reference that brucie quoted above seems to indicate that it isn't
valid though. It seems to indicate that you have the DTD, then
*everything* else is within the <html> element.

Duh! Just saw brucie's latest post - my bad. :-(

Must read things properly before commenting
Must read things properly before commenting
Must read things properly before commenting
Must read things prop...
 
M

Mark Parnell

brucie said:
GOODY GOODY! i'll get my whips and chains and camera and pointy stick
and bag of gravel and gaf tape and ...

....and plane ticket? I'm not in Queensland...
 
T

Toby A Inkster

Disco said:
Can a comment block (<!-- comment -->) be before the <html> tag.

Yes, but I wouldn't recommend putting anything before the <!DOCTYPE...>
tag because this could (wrongly) throw some browsers into quirks mode.
 
E

Eric B. Bednarz

Toby A Inkster said:
Disco wrote:

Since you are confused about some basic stuff (no problem, many people
are), some annotations might be useful:

The correct term is 'comment declaration', which conveniently implies
some hints about syntax.

The actual comments are one or more matching pairs of SGML COM
delimiters ('--') which appear between the SGML delimiters
MDO (markup declaration open: '<!') and
MDC (markup declaration close '>')
of a comment declaration. While the first COM delimiter must
immediately follow MDO without whitespace in between, the common
misconception is that the closing delimiter string of the comment
declaration is '-->'.

It isn't; any SGML characters are allowed in a comment, short of the
COM delimiter string '--' (because, naturally, it closes the open
comment).

<!-- don't feed these --
-->multiple comments --
-- to your web wowser<!--
-- but they are correct --
There's no such thing like an '<html> tag'; it's problematic to mix up
syntax and semantics because it adds to the general confusion when
discussing either of them.

There are only two tags in HTML: start tag and end tag. They delimit
the range of an element (like, in this case, an instance of the HTML
element type), but the generic identifier (the name of the element
type) in the tag is a property of the element, *not* the tag. In some
cases the generic identifier doesn't even need to occur in the tag, eg:

<table>
<tr>
<td>a table data cell
<>and another one
</table>

What information would 'the said:
Yes, but I wouldn't recommend putting anything before the <!DOCTYPE...>
tag because this could (wrongly) throw some browsers into quirks mode.

I would recommend doing that for precisely that reason, or better omit
the declaration altogether for robust results. (I'm not sure what you
mean by 'wrongly', 'correct doctype sniffing' would be an oxymoron.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top