View Single Post
Old 10-18-2010, 02:43 PM   #8
twobits
Addict
twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.twobits ought to be getting tired of karma fortunes by now.
 
Posts: 223
Karma: 1057019
Join Date: Oct 2010
Device: none
Quote:
Originally Posted by Connochaetes View Post
They don't do the same thing. <pre> preserves the layout (line breaks, whitespace) from the source file. <code> designates a phrase as code. An easy way to display indented code is to nest <code> within <pre>.

It is problematic at times on an eReader. I'll probably go with Falcao's solution - offer longer code snippets as a separate download. If I decide to take the plunge, that is.

Depends on the browser of course. <pre> is a bit out of place in some ways, since it moves formating into the markup which is something to try and avoid. <code> is more semantic so seems more the right way to mark up a code segment. Though it is not a block element, so I would probably
do something like

<p><code class="php">
<?php

phpinfo();
?>
</code></p>

Of course I would be changing the < and such into the proper entities in the source.

For indents I would throw in a blockquote for html 3.2, but with css I would just put it in the css. I put in the class="php" to add a bit more info to the tag, and maybe a future css would get enough features added to it , that a pretty printer could be done etc...

Idea is to make the markup code not have 'hacks' in it...

The w3c documents in fact give the same recommended css default for <pre> and <code>. It should be up to the device/renderer to pick its best way to render/format them. If there really is a current device that messes up with the <code> tag, then you could add in the css to make it work like pre I would think. Then when enough devices are fixed, change the css and not have to edit the html everywhere.

Last edited by twobits; 10-18-2010 at 03:56 PM.
twobits is offline   Reply With Quote