W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2009

[whatwg] <code> attributes

From: ddailey <ddailey@zoominternet.net>
Date: Wed, 29 Apr 2009 16:46:23 -0400
Message-ID: <46A6570E0F584A659A066B83EE911BA9@disxgdg31szkx7>


On  Tuesday, April 28, 2009 3:16 PM, Jacob Rask wrote:
> has there ever been any discussion on including an attribute to the
> code element, specify the programming language in the markup? If so,
> what was the conclusion? I didn't find anything in the list archives.

Having just converted a 200+ page document with a lot of in-lined code to 
HTML , I found myself
rather taxed by the limitations of <code> , so while I like your suggestion 
(which does seem
to appear in the draft spec [1]) , I need to offer some  observations of my 
own:

(disclaimer: I may well have been working on incorrect assumptions)
1. Having to type <pre><code>&lt;tagname></code></pre> seemed a little bit 
silly to me:
is there a use case for *not* wanting <pre> when doing <code>? Could that 
not be handled as an attribute of the <code> if so?
2. having to escape "<" as &lt; in the middle of <code> seems like work for 
the author that could just as easily be handled by the browser. In the old 
days, <xmp> worked pretty well... why no replacement for its functionality??
3. trying to style a <code> so that it would have an indented margin, a 
border, a default font-style (monospaced), preserve within -line 
indentation, and work consistently across browsers seemed to defy my humble 
abilities with CSS. (see 
http://srufaculty.sru.edu/david.dailey/cs427/StateOfArt-Dailey.html#test_file 
as an example of the very clumsy solution I ultimately opted for -- IE still 
doesn't preserve within-line indentation in this solution-- it used a styled 
table with a styled td and was particularly gross!.)
4. if we could just write
    <code language="xml">
    <html>
        <body>
            <svg><rect/></svg>
        </body>
    </html>
</code>,
it'd be nice to have the page render the HTML just as is.

5. Some of the good folks on either whatwg-irc or htmlwg-irc let me know 
that <code><p>happy</p><p>sad</p></code> was bad form, and that I should use 
<pre><code> instead. It never would have dawned on me that the first was bad 
form, nor that the second would be good form. (maybe it should have dawned 
on me, but I speak html sorta like I speak english, more through habit than 
training, and not very formally at that). Second the introduction of <p> 
within <code> was actually generated by a robot that converted a bunch of MS 
Word to <html> so someone other than me must have thought it was a good idea 
to do it that way.

regards
David

[1] 
http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-code-element 
Received on Wednesday, 29 April 2009 13:46:23 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:11 UTC