Footer & DOCTYPE

G

Goran Topic

Hello. I'm trying to make a footer, and I tried this (our site uses
table-based layout; don't kill me, please):

<table width="100%" height="100%">
<tr><td>
CONTENT HERE...
</td></tr>
<tr height="20px" bgcolor="blue"><td>
This is the footer
</td></tr>
</table>

And this works as I want it to: if the page is longer than the screen,
the footer goes at the bottom of the document; and if it's shorter, it
goes on the bottom of the screen. However, if I put the DOCTYPE
declaration, it does not work any more:

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

Can someone help me get this right? I should have the DOCTYPE, but I've
no idea how to get the same functionality with it.

Thanks,

Goran
 
M

Matthias Gutfeldt

Goran said:
Hello. I'm trying to make a footer, and I tried this (our site uses
table-based layout; don't kill me, please):

Just call it "hybrid layout" to make it buzzword compliant ;-)

<table width="100%" height="100%">
<tr><td>
CONTENT HERE...
</td></tr>
<tr height="20px" bgcolor="blue"><td>
This is the footer
</td></tr>
</table>

And this works as I want it to: if the page is longer than the screen,
the footer goes at the bottom of the document; and if it's shorter, it
goes on the bottom of the screen. However, if I put the DOCTYPE
declaration, it does not work any more:

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

Can someone help me get this right? I should have the DOCTYPE, but I've
no idea how to get the same functionality with it.

The TABLE element doesn't have a height attribute, see the HTML
specification: <http://www.w3.org/TR/html4/struct/tables.html#edef-TABLE>.

You don't say which browser you tested this in. Without the Doctype,
some browsers will just ignore the specification and apply the height
attribute. With the Doctype, same browsers will respect the
specification, and that means it will ignore the attribute.

Possible solution: Specify the height of the table (or its content) with
CSS.


Matthias
 
B

brucie

(our site uses table-based layout; don't kill me, please):

i'm sorry but it just doesn't work like that. death is really the only
solution. why should we kill everyone else and not you? are there
mitigating circumstances we should be aware of?
 
S

Steve Pugh

Goran Topic said:
Hello. I'm trying to make a footer, and I tried this (our site uses
table-based layout; don't kill me, please):

Okay. But I think you know why you're having problems.
<table width="100%" height="100%">
<tr><td>
CONTENT HERE...
</td></tr>
<tr height="20px" bgcolor="blue"><td>

That's wrong. The height attribute takes either a percentage or a
straight numerical value. It never takes a value with "px" tacked on
the end. Be careful that you don't mix up CSS and HTML syntax (lengths
in CSS must always have a unit, only percentage lengths in HTML have
units).
This is the footer
</td></tr>
</table>

And this works as I want it to: if the page is longer than the screen,
the footer goes at the bottom of the document; and if it's shorter, it
goes on the bottom of the screen. However, if I put the DOCTYPE
declaration, it does not work any more:

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

That doctype triggers standards mode in certain browsers (IE5 Mac, IE6
Win, Gecko based browsers, Opera 7) and in standards mode the invalid
height="100%" is ignored.
I should have the DOCTYPE, but I've no idea how to get the same functionality with it.

Why should you have the doctype? If you have <table height="100%">
then your page is _not_ HTML 4.01 Transitional so putting that doctype
there is telling a lie.

Either get rid of the height attribute or get rid of the doctype.

Or if you want to carry on telling lies you can change the doctype to
one that triggers quirks mode rather than standards mode (for example,
just delete the URL from the one above).

Steve
 
D

DU

Goran said:
Hello. I'm trying to make a footer, and I tried this (our site uses
table-based layout; don't kill me, please):

<table width="100%" height="100%">
<tr><td>
CONTENT HERE...
</td></tr>
<tr height="20px" bgcolor="blue"><td>
This is the footer
</td></tr>
</table>

And this works as I want it to: if the page is longer than the screen,
the footer goes at the bottom of the document; and if it's shorter, it
goes on the bottom of the screen. However, if I put the DOCTYPE
declaration, it does not work any more:

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

Can someone help me get this right? I should have the DOCTYPE, but I've
no idea how to get the same functionality with it.

Thanks,

Goran

Why didn't you just use entirely valid code in a tableless webpage
design? This is where your markup code and design will work on a
multitude of web-aware devices, platforms, compliant browsers, etc..
If you really need to use a table for tabular data, then why not use the
tfoot element?

http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3

Can you give an url of your webpage? That way, we could better suggest a
way for you to achieve your webpage requirements with web standards
compliance.

DU
 
N

Nico Schuyt

Why didn't you just use entirely valid code in a tableless webpage
design? This is where your markup code and design will work on a
multitude of web-aware devices, platforms, compliant browsers, etc..

Well, I'm not so sure about that
http://www.nicoschuyt.nl/test/footer.htm is an example of a tableless
solution for scrollable text with footer.
Bad keyboard navigation however and in browsers like Opera7.2 and Mozilla1.4
the scroll mouse is inactive.
Probably even more problems than frames :)
Nico
 
B

brucie

Well, I'm not so sure about that
http://www.nicoschuyt.nl/test/footer.htm is an example of a tableless
solution for scrollable text with footer.
Bad keyboard navigation however and in browsers like Opera7.2 and Mozilla1.4
the scroll mouse is inactive.
Probably even more problems than frames :)

a simpler solution would have just been to position a <div> at the
bottom of the window (or anywhere else you wanted it) with
position:fixed; so it remains in the location while everything else
scrolls.

easy peasy except once again for IE. you'll need the position fixed
fix. http://devnull.tagsoup.com/fixed/
 
J

Jukka K. Korpela

Steve Pugh said:
Or if you want to carry on telling lies you can change the doctype to
one that triggers quirks mode rather than standards mode

Alternatively, if you wish to tell the truth and you wish to use a
doctype declaration, you can create your copy of the Transitional DDT,
add a line that tells that a table element may have a height attribute,
upload the DTD onto a Web server, and refer to it your <!doctype>.

I'm pretty sure this will trigger "bug compatible" (aka. "quirks") mode
in current bwowsers. It will also let you check the markup syntax using
an SGML validator - why else would you use a <!doctype>?

Your page won't conform to any HTML specification, since all
specifications mandate the use of specific DTDs, even up to using a
specific way of referring them. But the great majority of Web pages
fails to conform, and virtually all bwowsers fail too, so you shouldn't
feel too sinful.
 
E

Eric Bohlman

Alternatively, if you wish to tell the truth and you wish to use a
doctype declaration, you can create your copy of the Transitional DDT,

Wasn't it Tina Marie Holmboe who, several years ago, wrote a parody of the
Ramones' "Teenage Lobotomy" that began with "DTD did a job on me"?
 
M

Matthias Gutfeldt

Jukka said:
Alternatively, if you wish to tell the truth and you wish to use a
doctype declaration, you can create your copy of the Transitional DDT,
add a line that tells that a table element may have a height attribute,
upload the DTD onto a Web server, and refer to it your <!doctype>.

I'm pretty sure this will trigger "bug compatible" (aka. "quirks") mode
in current bwowsers.

It depends. If you advertise the fact that it's your own DTD in the
Doctype Declaration, it might trigger Standard mode, since any
unrecognized Doctype triggers "Standard" mode, at least according to the
browser documentation and my own tests:
<http://gutfeldt.ch/matthias/articles/doctypeswitch/table.html>

So one would either have to use a W3C HTML Doctype (which might be seen
as 'lying'), or with a bit of care create a custom Doctype Declaration
that isn't recognized as "unknown".


Matthias
 
S

Steve Pugh

Nico Schuyt said:
Well, I'm not so sure about that
http://www.nicoschuyt.nl/test/footer.htm is an example of a tableless
solution for scrollable text with footer.
Bad keyboard navigation however and in browsers like Opera7.2 and Mozilla1.4
the scroll mouse is inactive.

However, the OP didn't ask for a fixed footer, but one that went to
the either the end of the window or the end of the content depending
on the amount of content. This is doable with CSS and doesn't seem to
screw up scrolling in any browser I have available for testing:

http://steve.pugh.net/test/test57.html (long content)
http://steve.pugh.net/test/test57a.html (short content)

Steve
 
J

Jukka K. Korpela

Eric Bohlman said:
Wasn't it Tina Marie Holmboe who, several years ago, wrote a parody
of the Ramones' "Teenage Lobotomy" that began with "DTD did a job
on me"?

I swear by SGML and XML and the holy W3C that "DDT" was an
unintentional typo. Consult "Psychopathologie des Alltagslebens" for a
background explanation.
 
J

Jukka K. Korpela

Matthias Gutfeldt said:
It depends. If you advertise the fact that it's your own DTD in the
Doctype Declaration, it might trigger Standard mode, since any
unrecognized Doctype triggers "Standard" mode, at least according
to the browser documentation and my own tests:
<http://gutfeldt.ch/matthias/articles/doctypeswitch/table.html>

Excuse me while I get mad.

And sorry for making guesses on the basis of what would have made at
least _some_ sense, instead of checking what bwowser vendors actually
did. Incidentally, it seems that your article is blank (white) for
Netscape 6 as regards to the mode when an "unrecognized" doctype is
used - at least Netscape 7.1 seems to follow the crowd, in doing just
the absurd thing: if I declare a doctype in a manner that definitely
violates HTML specifications (even if I in fact thereby refer to a DTD
that is a verbatim copy of a DTD listed in a specification), the
doctype sniffer decides to switch to "standards" mode.
So one would either have to use a W3C HTML Doctype (which might be
seen as 'lying'), or with a bit of care create a custom Doctype
Declaration that isn't recognized as "unknown".

Quite interesting options, are they not? So the logical conclusion is
that the need for declaring a doctype (when you actually want "quirks"
mode) is nonexistent, except if company police requires it. After all,
the doctype has two effective meanings:
a. For SGML validators, as well as some of their imitations, the
doctype declaration is a way of expressing the intended syntax
in a manner that allows automatic verification. But the author
can of course submit a modified copy, which contains a suitable
doctype.
b. Browsers play their games, in different ways, modifying the rules
of the game in a Calvinball-like manner. But if quirks mode is what
you want, omission of any doctype seems to be the best method
(at present at least).
 
M

Matthias Gutfeldt

Jukka K. Korpela said:
Excuse me while I get mad.

Take your time. Just ring the bell when you're finished smashing the
furniture and dishes :).

Incidentally, it seems that your article is blank (white) for
Netscape 6 as regards to the mode when an "unrecognized" doctype is
used

Yes. IIRC I forgot to test it before I banished NN6 from my computer.

- at least Netscape 7.1 seems to follow the crowd, in doing just
the absurd thing: if I declare a doctype in a manner that definitely
violates HTML specifications (even if I in fact thereby refer to a DTD
that is a verbatim copy of a DTD listed in a specification), the
doctype sniffer decides to switch to "standards" mode.

Absolutely. This particular problem illustrates nicely that Doctype
Switch is not only a bad idea, it's also very badly executed.

Add to this the two following simple observations:

a) Many authors don't even know about this "feature", and accidently
trigger "Standard" mode although their document is confused tag-soup, or
"Quirks" mode although their document follows the specification
b) Some browsers introduced errors in "Quirk" mode-capable browser that
they never had in previous versions (Opera,
<http://www.opera.com/docs/specs/doctype/>)

It becomes clear, at least to me, that the Doctype Switch should be
abolished as soon as possible.


Matthias
 
T

Toby A Inkster

Jukka said:
the absurd thing: if I declare a doctype in a manner that definitely
violates HTML specifications (even if I in fact thereby refer to a DTD
that is a verbatim copy of a DTD listed in a specification), the
doctype sniffer decides to switch to "standards" mode.

To be honest that makes perfect sense to me -- it allows the browser to
display a theoretical "HTML 5.0"[1] document in standards mode.

[1] or any possible future HTML-like markup language.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top