By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,983 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,983 IT Pros & Developers. It's quick & easy.

XHTML standard rationale question

P: n/a
Why does the standard require that certain elements have certain child
elements? For example, the <head> element must have a <title> element
as a child, and <table> must have at least one <tr> child element.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
Share this Question
Share on Google+
23 Replies


P: n/a
Christopher Benson-Manica wrote:
Why does the standard require that certain elements have certain child
elements? For example, the <head> element must have a <title> element
as a child, and <table> must have at least one <tr> child element.


Because it is logical that:
1. Every document must have a title?
2. Every Table must have a Table Row?

--
Gus
Jul 23 '05 #2

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Why does the standard require that certain elements have certain child
elements? For example, the <head> element must have a <title> element
as a child, and <table> must have at least one <tr> child element.


The two examples you give are also rerquirements in HTML, not just in
XHTML.

To turn your questions around-
Why should a document exist without a title?
Why should a table exist without any rows?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #3

P: n/a
Christopher Benson-Manica wrote:
Why does the standard require that certain elements have certain child
elements?
Both HTML and XHTML require children for certain elements. I'm of the
opinion that some elements don't make sense without content.

For example, a paragraph isn't much of a paragraph without text
content. Whilst the HTML Specification allows an empty P element, it
does discourage them and suggests that user agents ignore them. I
expect that content isn't a requirement because of empty paragraph
hacks used in legacy documents.
For example, the <head> element must have a <title> element as a child,
As the HTML Specification implies in the quote below
(<URL:http://www.w3.org/TR/html4/struct/global.html#h-7.4.2>), the
TITLE element has an important purpose from an accessibility
perspective. The TITLE element is also extremely important for search
engines.

"For reasons of accessibility, user agents must always make the
content of the TITLE element available to users"

As any reasonable document has a title, an HTML document should have a
TITLE element. Moreover, for a user agent to conform with the quoted
statement, a document must have a title to make available.
and <table> must have at least one <tr> child element.


A table is a very good example of what I said previously: it isn't
very meaningful without any content, is it?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

P: n/a
Steve Pugh <st***@pugh.net> spoke thus:
Why should a document exist without a title?
Why should a table exist without any rows?


Say, for example, that the title of the document is generated by
script. Given the standard, one must include an empty title element
to enable validation of the page. Similarly, a CGI must check that
there are elements to put in a table before it writes the open and
close tags.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #5

P: n/a
Michael Winter <m.******@blueyonder.co.invalid> spoke thus:
Both HTML and XHTML require children for certain elements. I'm of the
opinion that some elements don't make sense without content.
They may not make sense, but if UA's ignore them I don't see the harm
in permitting them in conforming documents.
As any reasonable document has a title, an HTML document should have a
TITLE element. Moreover, for a user agent to conform with the quoted
statement, a document must have a title to make available.


The title element is, I suppose, a special case...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #6

P: n/a
On Sun, 13 Feb 2005 23:41:17 +0000 (UTC), Christopher Benson-Manica
<at***@nospam.cyberspace.org> wrote:
Steve Pugh <st***@pugh.net> spoke thus:
Why should a document exist without a title?
Why should a table exist without any rows?


Say, for example, that the title of the document is generated by
script. Given the standard, one must include an empty title element
to enable validation of the page. Similarly, a CGI must check that
there are elements to put in a table before it writes the open and
close tags.


This is reasonable.

A recent change to the RSS specification(s) was to clarify that an
enpty list of <item>s was a valid RSS document. This is quite
reasonable, because (as you say) there can be automatically-generated
cases when there simply are no such items in scope.

For the case of <title> though, all HTML documents have a title. There
is _always_ a sensible interpretation for the title of the document,
even if this is merely re-stating the URL.

In the case of <tr> within a <table>, then the null <table> is
meaningless. The table may well be empty, but this should suppress the
entire <table>, not just its content (this does not exclude a table
empty of data that still has a header).

Jul 23 '05 #7

P: n/a
Christopher Benson-Manica wrote:
Steve Pugh <st***@pugh.net> spoke thus:

Why should a document exist without a title?
Why should a table exist without any rows?


Say, for example, that the title of the document is generated by
script.


Say for example, a user agent that doesn't support script or has it
disabled? You really need to think about accessibility and graceful
degredation in such cases. BTW, AFAIK, Google doesn't support script,
so google won't see your title and that may lower your ranking. There
will also be nothing for google to show as the title in search results.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://SpreadFirefox.com/ Igniting the Web
Jul 23 '05 #8

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Steve Pugh <st***@pugh.net> spoke thus:
Why should a document exist without a title?
Why should a table exist without any rows?
Say, for example, that the title of the document is generated by
script. Given the standard, one must include an empty title element
to enable validation of the page.


A script on the server or client side?

If on the server then there's no problem. You should be validating
your output - the same code that gets sent to the browser.

If client side then your pages have no titles as far as users (or
search engines) without scripting are concerned and hence the
validator is quite correct in saying that they are broken.
Similarly, a CGI must check that
there are elements to put in a table before it writes the open and
close tags.


Yes. That's the right way to do it.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #9

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Steve Pugh <st***@pugh.net> spoke thus:
Why should a document exist without a title?
Why should a table exist without any rows?
Say, for example, that the title of the document is generated by
script. Given the standard, one must include an empty title element
to enable validation of the page.


No, one must include _a_ title element. Making its content empty is your
choice and cannot, unfortunately, be prevented by a DTD.

If validation tells you that a document without a title element is invalid,
then it's a _good_ thing. That's the kind of things that DTDs and
validators are for.

If a script generates an HTML document without a title, then it's a broken
script. Fix it, don't complain about a tool that revealed the error.
Similarly, a CGI must check that
there are elements to put in a table before it writes the open and
close tags.


And this too is indeed a _good_ thing. It may imply that a script may need
to use buffering, e.g. generate the lines into an internal string, then
check whether it's empty before generating table markup. Or you might use a
Boolean variable that tells whether the start of table markup has been
generated. Or something else, perhaps more tree-oriented.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #10

P: n/a
Christopher Benson-Manica wrote:
Michael Winter <m.******@blueyonder.co.invalid> spoke thus:
Both HTML and XHTML require children for certain elements. I'm of
the opinion that some elements don't make sense without content.


They may not make sense, but if UA's ignore them I don't see the
harm in permitting them in conforming documents.


If UAs ignore them, why include them in the first place? You're just
adding unnecessary bulk to a document that a UA will have to spend
time stripping out.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #11

P: n/a
Michael Winter <m.******@blueyonder.co.invalid> wrote:
They may not make sense, but if UA's ignore them I don't see the harm
in permitting them in conforming documents.


If UAs ignore them, why include them in the first place?


Besides, it is not a requirement that UAs ignore, say, <table></table>.
It is syntactically erroneous, so browsers could do whatever they want.
If the syntax were changed to allow it, then a well-designed specification
would have to define its _meaning_ as well. What might that be? And
browsers would need to decide on the rendering.

For example, a browser might use some default top and bottom margin for a
table. Should it suppress that for an empty table, if it were allowed.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #12

P: n/a
Christopher Benson-Manica wrote:
Michael Winter <m.******@blueyonder.co.invalid> spoke thus:

Both HTML and XHTML require children for certain elements. I'm of the
opinion that some elements don't make sense without content.

They may not make sense, but if UA's ignore them I don't see the harm
in permitting them in conforming documents.


It's not a question of harm, it's a question of declaring what the
meaning of a TABLE is. A table is fundamentally a collection of rows, at
least one, so it's defined that way. Likewise with a list: a list
without items is meaningless, so a UL is defined to contain *one* or
more items, not zero or more.

Why *would* someone want to put a TABLE element with no rows on a page?
Jul 23 '05 #13

P: n/a
Steve Pugh <st***@pugh.net> spoke thus:
A script on the server or client side?
Client side; I knew I should have specified, sorry.
If client side then your pages have no titles as far as users (or
search engines) without scripting are concerned and hence the
validator is quite correct in saying that they are broken.
Our pages are never indexed by search engines anyway, and indeed until
I got ahold of them they were CGI scripts that weren't indexed anyway.
Yes. That's the right way to do it.


Only because that's the way the standard is written...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #14

P: n/a
Jukka K. Korpela <jk******@cs.tut.fi> spoke thus:
For example, a browser might use some default top and bottom margin for a
table. Should it suppress that for an empty table, if it were allowed.


I would say that a pretty simple standard would be that any empty
element would be rendered as though it had a value of "none" for the
display property.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #15

P: n/a
Jukka K. Korpela <jk******@cs.tut.fi> spoke thus:
And this too is indeed a _good_ thing. It may imply that a script may need
to use buffering, e.g. generate the lines into an internal string, then
check whether it's empty before generating table markup. Or you might use a
Boolean variable that tells whether the start of table markup has been
generated. Or something else, perhaps more tree-oriented.


There are certainly ways around the issue, but if empty elements were
allowed none of them would be necessary.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #16

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
For example, a browser might use some default top and bottom margin
for a table. Should it suppress that for an empty table, if it were
allowed.


I would say that a pretty simple standard would be that any empty
element would be rendered as though it had a value of "none" for the
display property.


But to see whether an element is empty, a browser would need to investigate
its content as a separate ad hoc test. It makes more sense to do such
things when the document is _generated_, especially since it is difficult
to assign any sensible _meaning_ to an empty table or empty list, for
example

Moreover, it would raise the question what is empty. <p></p> is surely
empty, but what about <p> </p>? Or <p>&nbsp;</p>?

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #17

P: n/a
Jukka K. Korpela <jk******@cs.tut.fi> spoke thus:
But to see whether an element is empty, a browser would need to investigate
its content as a separate ad hoc test. It makes more sense to do such
things when the document is _generated_, especially since it is difficult
to assign any sensible _meaning_ to an empty table or empty list, for
example


That's what I was looking for, it makes sense to me now. Thanks.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #18

P: n/a
Christopher Benson-Manica wrote:
Our pages are never indexed by search engines anyway...


How can you possibly justify that statement? If anyone had ever linked
to your site and it was available to the public on the WWW, it is highly
likely that google and other search engines will have indexed your site.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://SpreadFirefox.com/ Igniting the Web
Jul 23 '05 #19

P: n/a
Lachlan Hunt <sp***********@gmail.com> spoke thus:
How can you possibly justify that statement? If anyone had ever linked
to your site and it was available to the public on the WWW, it is highly
likely that google and other search engines will have indexed your site.


But it *isn't* available to the public on the WWW. Users must be
logged in to get to these pages, and the Google robot does not have an
account with us :)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #20

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Lachlan Hunt <sp***********@gmail.com> spoke thus:
How can you possibly justify that statement? If anyone had ever linked
to your site and it was available to the public on the WWW, it is highly
likely that google and other search engines will have indexed your site.


But it *isn't* available to the public on the WWW.


So why did you post to this newsgroup? Did you miss the WWW in the
group name?

If you are creating private documents for private use then use a
private DTD and validate against that. Then you can redefine the
semantics of your private HTML-like-language to be whatever suits your
purposes.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #21

P: n/a
Steve Pugh <st***@pugh.net> spoke thus:
So why did you post to this newsgroup? Did you miss the WWW in the
group name?


Well, I'm glad I did in any case, and I appreciate the responses I've
gotten.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #22

P: n/a
Christopher Benson-Manica wrote:
Steve Pugh <st***@pugh.net> spoke thus:


[quote reinserted to make sense of what follows]
Similarly, a CGI must check that there are elements to put in a
table before it writes the open and close tags.


Yes. That's the right way to do it.

Only because that's the way the standard is written...


Well, yeah, that's the point of the standard, right? To require certain
things, or make their inclusion the "right way to do it".

--
Brian
Jul 23 '05 #23

P: n/a
begin quote from Christopher Benson-Manica in message
<cu**********@chessie.cirr.com> on Sun 2005 February 13 17:41:
Steve Pugh <st***@pugh.net> spoke thus:
Why should a document exist without a title?
Why should a table exist without any rows?


Say, for example, that the title of the document is generated by
script.


Scripting is always optional. Many user agents (browsers) do not support
scripting at all, and those that do always let you disable it.

--
Shawn K. Quinn
Jul 23 '05 #24

This discussion thread is closed

Replies have been disabled for this discussion.