[wp-hackers] Code Tag Driving me Nuts!!

Geoffrey Sneddon foolistbar at googlemail.com
Sun Oct 29 14:47:50 GMT 2006

On 29 Oct 2006, at 13:02, Petit wrote:

> Computer Guru wrote:
>> Is the <code></code> tag supposed to (in WP) display whatever is  
>> in between
>> it tit-for-tat or is it supposed to parse the HTML within?
>> It's driving me _nuts_!
>> I'm trying to put up a post that has more code than normal text,  
>> and I just
>> can't for the life of me figure out how to get my stuff to display  
>> right!
>> If I put un-encoded HTML straight into the <code> tags, it'll  
>> display OK in
>> WP, but it'll completely screw up my other apps that use the WP  
>> database.
>> Computer Guru
>> NeoSmart Technologies
>> http://neosmart.net/blog/
> Without testing it, out of my sleepy hat, I'd propose that you use  
> escaped code within a <pre> tag to preserve formatting.
> For styling I'd use <pre class="code">some code here</pre> and a  
> CSS rule for .code.
> That should work I guess. ( hopefully my "tags" above doesn't break  
> anything ;)

It'd be semantically better to use <pre><code>[escaped HTML]</code></ 
pre> then use a CSS rule for pre code (if not pre > code). pre has a  
semantic meaning of "whitespace within this element has meaning", and  
code has a semantic meaning of "there is computer code within this  
element". Therefore, you should be using pre and code for code where  
whitespace has meaning.

- Geoffrey Sneddon.

More information about the wp-hackers mailing list