W3C home > Mailing lists > Public > www-validator@w3.org > July 2008

Re: <pre><img src="test.gif" alt="test" /></pre>

From: Frank Ellermann <nobody@xyzzy.claranet.de>
Date: Wed, 9 Jul 2008 07:11:36 +0200
To: www-validator@w3.org
Message-ID: <g51h5k$nmn$1@ger.gmane.org>

Fredrik Medin wrote:

> You get an error when you do it like this:
> <pre><img src="test.gif" alt="test" /></pre>
 
> And still it shows perfectly in both IE and FF.

Yeah, that is just as it is, the syntax does not
allow images within <pre>.  Even where that could
work, depending on the browser and the image. 

Things you can do:
(1) Ignore the error if you are sure that you are
    not interested to find another solution.
(2) Cheat, put the image into a <span> within the
    <pre>.  That's actually a variant of (1), and
    it only works because *this* validator at the
    moment isn't smart enough to detect that trick.
(3) Roll your own syntax allowing what you want.
    That's utter dubious, because you likely don't
    know all reasons why it's not permitted in the
    official specification.
(4) Use image within <tt> instead of <pre> if all
    you want is mono-spaced.  Don't try that in
    HTML5-asinine, where they intend to kill <tt>.
(5) Use image within <span> instead of <pre> with
    span-styles doing what you want for browsers
    supporting CSS.
(6) Use image within <div> instead of <pre> with
    span-styles doing what you want for browsers
    supporting CSS.  (4) or (5) vs. (6) are very
    similar, and it depends on the context what's
    allowed and/or better.

Lots of options, 

 Frank
-- 
<http://omniplex.blogspot.com/2008/07/html5-asinine-selfish.html>
Received on Wednesday, 9 July 2008 05:09:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:30 GMT