Connecting Tech Pros Worldwide Help | Site Map

img inside pre

Jarno Suni not@here.invalid
Guest
 
Posts: n/a
#1: Sep 17 '05

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?
Spartanicus
Guest
 
Posts: n/a
#2: Sep 17 '05

re: img inside pre


"Jarno Suni" not@here.invalid wrote:

[img inside pre]
[color=blue]
>It seems to be invalid in HTML 4.01, but valid in XHTML 1.0.[/color]

It's invalid under both.

--
Spartanicus
David Dorward
Guest
 
Posts: n/a
#3: Sep 17 '05

re: img inside pre


"Jarno Suni" not@here.invalid wrote:
[color=blue]
> It seems to be invalid in HTML 4.01, but valid in XHTML 1.0.[/color]

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
Jarno Suni not@here.invalid
Guest
 
Posts: n/a
#4: Sep 18 '05

re: img inside pre


[color=blue]
> 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.[/color]

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.
[color=blue]
> [1] Please contain your whole message in the body text[/color]

Ok, if it helps. Sorry for not being precise in my original message.
Henri Sivonen
Guest
 
Posts: n/a
#5: Sep 18 '05

re: img inside pre


In article <5kbXe.102$dx4.53@read3.inet.fi>,
"Jarno Suni" not@here.invalid wrote:
[color=blue][color=green]
> > 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.[/color]
>
> 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.[/color]

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

--
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Jukka K. Korpela
Guest
 
Posts: n/a
#6: Sep 18 '05

re: img inside pre


Henri Sivonen <hsivonen@iki.fi> wrote:
[color=blue][color=green]
>> <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.[/color]
>
> XML DTDs are more limited in their expressiveness. The inability to
> express exclusions like that is one of the limitations.[/color]

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

Jarno Suni not@here.invalid
Guest
 
Posts: n/a
#7: Sep 18 '05

re: img inside pre


[color=blue]
> In article <5kbXe.102$dx4.53@read3.inet.fi>,
> "Jarno Suni" not@here.invalid wrote:[/color]
[color=blue][color=green]
> > <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.[/color]
>
> XML DTDs are more limited in their expressiveness. The inability to
> express exclusions like that is one of the limitations.[/color]

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?
David Dorward
Guest
 
Posts: n/a
#8: Sep 18 '05

re: img inside pre


"Jarno Suni" not@here.invalid wrote:
[color=blue]
> I believe you. But
> <pre><a><img src="image.png" alt="" /></a></pre>
> validates as XHTML 1.0 Strict[/color]

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
Jarno Suni not@here.invalid
Guest
 
Posts: n/a
#9: Sep 18 '05

re: img inside pre


[color=blue]
> "Jarno Suni" not@here.invalid wrote:
>[color=green]
> > I believe you. But
> > <pre><a><img src="image.png" alt="" /></a></pre>
> > validates as XHTML 1.0 Strict[/color]
>
> Valid, but non-conformant:
> http://www.w3.org/TR/xhtml1/#h-4.9
> http://www.w3.org/TR/xhtml1/#prohibitions[/color]

Thanks, this clarifies the dilemma and gives me the reason to use different code.
Closed Thread