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

Prohibited nesting questions

P: n/a
I just read the note under the XHTML spec
(http://www.w3.org/TR/xhtml1/#h-4.9) that explains how XML DTD
notation doesn't provided for the exclusion of elements from
containment by the element being defined. For example, there is no way
to indicate that an <a> element can't contain another one.

I see that the strict HTML DTD shows

-(A)

in the definition of the <a> element. But AFAIK this means that an
anchor can't *directly* contain another one, and it doesn't cover a
situation like (attributes omitted)

<a>some <i>italicized <a>text</a> goes </i>here</a>

I looked for a note in the HTML spec that would correspond with the
one in the XHTML notes indicating that the above code isn't
acceptable, but didn't find one. Can anyone explain the particulars?

By the way, in the XHTML notes, only a few specific prohibitions are
noted (http://www.w3.org/TR/xhtml1/#prohibitions), but these don't
include nested <i>. What, in either XHTML or HTML, prevents an <i>
nested inside another one? Or am I wrong that such nesting is
prohibited--but in that case, what is the meaning of nested <i>?

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ter le premier point de mon adresse de courriel.
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Harlan Messinger <hm*******************@comcast.net> wrote:
By the way, in the XHTML notes, only a few specific prohibitions are
noted (http://www.w3.org/TR/xhtml1/#prohibitions), but these don't
include nested <i>. What, in either XHTML or HTML, prevents an <i>
nested inside another one? Or am I wrong that such nesting is
prohibited--but in that case, what is the meaning of nested <i>?


Nested <i> are permitted. It has no meaning, just as <i> doesn't
really have any meaning either.

(Though as many cases of italics are false italics created by the
user's computer manipulating a basic font rather than by using a
designed italics font, the horrible possiblity exists that nested <i>
could lead to raelly ugly extra-slanted false italics.)

With CSS you can of course use
i {font-style: italic;}
i i {font-style: normal;}
which complies with normal typography and makes life easier for
authors, style guides and content management systems. (e.g. text in a
foreign language and names of vessels are simply marked up using <i>,
even when one is contained within the other).

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 20 '05 #2

P: n/a
Harlan Messinger <hm*******************@comcast.net> wrote:
I just read the note under the XHTML spec
(http://www.w3.org/TR/xhtml1/#h-4.9) that explains how XML DTD
notation doesn't provided for the exclusion of elements from
containment by the element being defined.
Quite right. This puts the widespread cargo cult slogan
"XHTML is more rigorous than tag-soup HTML" into perspective.
For example, there is no
way to indicate that an <a> element can't contain another one.
Actually, the DTD could be rewritten to disallow <a> elements within
<a> elements. But it would mean lots of rules.
I see that the strict HTML DTD shows

-(A)

in the definition of the <a> element.
Ditto in other HTML DTDs.
But AFAIK this means that an
anchor can't *directly* contain another one, and it doesn't cover a
situation like (attributes omitted)

<a>some <i>italicized <a>text</a> goes </i>here</a>
No, it forbids that too. A validator will report an error.

The meaning of -(A) in a DTD is defined, in the SGML standard, in a
manner that excludes any occurrence of A in the content, either
directly as a subelement, or as a subelement of subelement etc.
I looked for a note in the HTML spec that would correspond with
the one in the XHTML notes indicating that the above code isn't
acceptable, but didn't find one. Can anyone explain the
particulars?
In principle there is no need to say in prose something that is said in
a formalized manner in a DTD. In practice, few people read DTDs, and
even fewer understand them.
By the way, in the XHTML notes, only a few specific prohibitions
are noted (http://www.w3.org/TR/xhtml1/#prohibitions), but these
don't include nested <i>. What, in either XHTML or HTML, prevents
an <i> nested inside another one?
Nothing.
Or am I wrong that such nesting
is prohibited--but in that case, what is the meaning of nested <i>?


The same as unnested. Physical markup like <i> is idempotent. Not all
physical markup is; for example <big><big>...</big></big> could be
argued as indicating bigger than big (the specification is vague), and
that's how browsers treat it. A case could be made for
<b><b>...</b></b> too, since bolding could be viewed as relative, but
it seems that browsers don't behave that way - they treat <b> as
correspong to CSS declaration font-weight: bold even in situations
where more than one degree of bolding exists (which depends on the font
and on the browser etc.).

The semantics of nested markup is generally vaguely defined, or left
completely undefined, in HTML specs. The general idea is probably that
nested emphasis _should_ be honored, but browsers really don't bother.
Consider <em>...<em>...</em>...</em>. A good implementation, if it uses
italics, would switch to upright style for the inner <em> element or
otherwise indicate it as different from the surrounding text. But to
browsers, <em> is just a synonym for <i>, though kept as a separate
symbol so that you can _style_ it differently. Ooops, I seem to have
revealed a secret that we Purists have tried to protect from the masses
who would misunderstand it... :-)

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

Jul 20 '05 #3

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fi> writes:
Harlan Messinger <hm*******************@comcast.net> wrote:
Or am I wrong that such nesting
is prohibited--but in that case, what is the meaning of nested <i>?


The same as unnested. Physical markup like <i> is idempotent. Not all
physical markup is; for example <big><big>...</big></big> could be
argued as indicating bigger than big (the specification is vague), and
that's how browsers treat it. A case could be made for
<b><b>...</b></b> too, since bolding could be viewed as relative, but
it seems that browsers don't behave that way - they treat <b> as
correspong to CSS declaration font-weight: bold even in situations
where more than one degree of bolding exists (which depends on the font
and on the browser etc.).


Though
b {
font-weight: bolder;
}

would be straightforward enough to put into an author stylesheet.
Unfortunately few browsers implement the whole range well, most seem
to only do
100-500 = 400
600-800 = 700
900 = 900 or 700 or mangled [1]

[1] Someone else's IE installation. It looked absolutely fine on
mine. Font problems of some sort, but I wasn't able to go to see the
browser first-hand to confirm.

--
Chris
Jul 20 '05 #4

P: n/a
On Tue, 17 Feb 2004, Jukka K. Korpela wrote:
The same as unnested. Physical markup like <i> is idempotent.


However, there's nothing stopping you from defining a different
style for "i i" than for "i" in CSS, if you are so inclined. And the
same for your "b b" example too.

What it would actually _mean_ is of course a different matter, as you
said.
Jul 20 '05 #5

P: n/a
On Tue, 17 Feb 2004 14:06:10 +0000, Alan J. Flavell <fl*****@ph.gla.ac.uk>
wrote:
On Tue, 17 Feb 2004, Jukka K. Korpela wrote:
The same as unnested. Physical markup like <i> is idempotent.


However, there's nothing stopping you from defining a different
style for "i i" than for "i" in CSS, if you are so inclined. And the
same for your "b b" example too.

What it would actually _mean_ is of course a different matter, as you
said.

I did once see a style sheet with

em {
font-style: italic;
}
em em {
font-style: normal;
}

in order to allow for double-level emphasis, but I never saw an example of
this on the page in question.
Jul 20 '05 #6

P: n/a

"Neal" <ne*****@spamrcn.com> wrote in message
news:op**************@news.rcn.com...
On Tue, 17 Feb 2004 14:06:10 +0000, Alan J. Flavell <fl*****@ph.gla.ac.uk>
wrote:
On Tue, 17 Feb 2004, Jukka K. Korpela wrote:
The same as unnested. Physical markup like <i> is idempotent.


However, there's nothing stopping you from defining a different
style for "i i" than for "i" in CSS, if you are so inclined. And the
same for your "b b" example too.

What it would actually _mean_ is of course a different matter, as you
said.

I did once see a style sheet with

em {
font-style: italic;
}
em em {
font-style: normal;
}

in order to allow for double-level emphasis, but I never saw an example of
this on the page in question.


That makes sense. I've done something similar, when I've had a class for
which I specified italic printing:

.myClass { font-style: italic; }
.myClass em { font-style: normal; }

Jul 20 '05 #7

P: n/a
In article <op**************@news.rcn.com>, Neal <ne*****@spamrcn.com>
wrote:
On Tue, 17 Feb 2004 14:06:10 +0000, Alan J. Flavell <fl*****@ph.gla.ac.uk>
wrote:
On Tue, 17 Feb 2004, Jukka K. Korpela wrote:
The same as unnested. Physical markup like <i> is idempotent.


However, there's nothing stopping you from defining a different
style for "i i" than for "i" in CSS, if you are so inclined. And the
same for your "b b" example too.

What it would actually _mean_ is of course a different matter, as you
said.

I did once see a style sheet with

em {
font-style: italic;
}
em em {
font-style: normal;
}

in order to allow for double-level emphasis, but I never saw an example of
this on the page in question.


The question would be, what would happen to text within three levels of
<em></em>?

--
| Andrew Glasgow <amg39(at)cornell.edu> |
|"I am astounded ... at the wonderful power you have developed -- and |
|terrified at the thought that so much hideous and bad music may be put on |
|record forever." -- Arthur Sullivan, 1888, upon viewing Edison's phonograph|
Jul 20 '05 #8

P: n/a
Andrew Glasgow <am***@cornell.edu> wrote:
I did once see a style sheet with

em {
font-style: italic; }
em em {
font-style: normal; }

in order to allow for double-level emphasis, but I never saw an
example of this on the page in question.


The question would be, what would happen to text within three
levels of <em></em>?


The innermost element would take the style defined for "em em",
i.e. font-style: normal. And this in turn could be prevented by
replacing the selector "em" in the first rule by the selector list
"em em em". And so on. It's quite manageable in an author style sheet.
But in practice you would hardly use such nesting anyway.

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

Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.