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

img inside pre

P: n/a

It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
Sep 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Jarno Suni" no*@here.invalid wrote:

[img inside pre]
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0.


It's invalid under both.

--
Spartanicus
Sep 17 '05 #2

P: n/a
"Jarno Suni" no*@here.invalid wrote:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0.


I created two test documents and compared. It (assuming you mean <pre>
elements containing <img> elements[1]) is invalid in both HTML 4.01 Strict
and XHTML 1.0 Strict.

[1] Please contain your whole message in the body text

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 17 '05 #3

P: n/a
I created two test documents and compared. It (assuming you mean <pre>
elements containing <img> elements[1]) is invalid in both HTML 4.01 Strict
and XHTML 1.0 Strict.
I believe you. But
<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict whereas
<pre><a><img src="image.png" alt=""></a></pre>
does not validate as HTML 4.01 Strict, when I used http://validator.w3.org/ for validation.
[1] Please contain your whole message in the body text


Ok, if it helps. Sorry for not being precise in my original message.
Sep 18 '05 #4

P: n/a
In article <5k**************@read3.inet.fi>,
"Jarno Suni" no*@here.invalid wrote:
I created two test documents and compared. It (assuming you mean <pre>
elements containing <img> elements[1]) is invalid in both HTML 4.01 Strict
and XHTML 1.0 Strict.


I believe you. But
<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict whereas
<pre><a><img src="image.png" alt=""></a></pre>
does not validate as HTML 4.01 Strict, when I used http://validator.w3.org/
for validation.


XML DTDs are more limited in their expressiveness. The inability to
express exclusions like that is one of the limitations.

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Sep 18 '05 #5

P: n/a
Henri Sivonen <hs******@iki.fi> wrote:
<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict whereas
<pre><a><img src="image.png" alt=""></a></pre>
does not validate as HTML 4.01 Strict, when I used
http://validator.w3.org/ for validation.


XML DTDs are more limited in their expressiveness. The inability to
express exclusions like that is one of the limitations.


The XHTML 1.0 DTD tries to overcome the limitation by using a special
content model for the <pre> element:

<!-- pre uses %Inline excluding big, small, sup or sup -->

<!ENTITY % pre.content
"(#PCDATA | a | %fontstyle; | %phrase; | %special.pre; | %misc.inline;
| %inline.forms;)*">

This won't make <pre><a><img src="image.png" alt=""></a></pre> invalid,
though, since the rules are satisfied: <pre> contains just the <a> element,
which is allowed of course, and the content model of <a> allows any inline
content, including <img>.

It would be possible, but highly impractical, to write XML syntax rules in
a manner that corresponds to the HTML rules for <pre>. You would
essentially have to duplicate a large number of syntax rules, having both
"general version" and "pre version". Besides, the whole point in those
<pre> rules is questionable. The intent is to disallow markup that might
cause font size to change or might introduce anything that is not
representable as a "character cell". Yet, allowing e.g. form fields inside
<pre> works against this idea, and sounds rather pointless.

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

Sep 18 '05 #6

P: n/a
In article <5k**************@read3.inet.fi>,
"Jarno Suni" no*@here.invalid wrote:

<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict whereas
<pre><a><img src="image.png" alt=""></a></pre>
does not validate as HTML 4.01 Strict, when I used http://validator.w3.org/
for validation.


XML DTDs are more limited in their expressiveness. The inability to
express exclusions like that is one of the limitations.


Do you mean I should avoid using the XHTML code even if it validates?
Can I trust that the XHTML is displayed the same way when served as application/xhtml+xml and text/html?
Sep 18 '05 #7

P: n/a
"Jarno Suni" no*@here.invalid wrote:
I believe you. But
<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict


Valid, but non-conformant:
http://www.w3.org/TR/xhtml1/#h-4.9
http://www.w3.org/TR/xhtml1/#prohibitions

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 18 '05 #8

P: n/a
"Jarno Suni" no*@here.invalid wrote:
I believe you. But
<pre><a><img src="image.png" alt="" /></a></pre>
validates as XHTML 1.0 Strict


Valid, but non-conformant:
http://www.w3.org/TR/xhtml1/#h-4.9
http://www.w3.org/TR/xhtml1/#prohibitions


Thanks, this clarifies the dilemma and gives me the reason to use different code.
Sep 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.