Thursday, November 4, 2010

Styling code blocks

In this article I'll explain how to use CSS for styling code blocks. Code blocks are generally formatted by using the pre element. Roger Johansson has proposed another way to accomplish this task and I'll follow his example with further improvements.

Table of contents

The markup

The proposed markup for code blocks is the following:
Listing 1. Proposed markup for code blocks

<ol class="code">
<li><code>/* static */</code></li>
<li class="indent1"><code>gLexTableSetup = PR_TRUE;</code></li>
<li class="indent2"><code>lt[i] |= IS_IDENT | START_IDENT;</code></li>
<li class="indent3"><code>lt[i] |= IS_HEX_DIGIT;</code></li>
<li id="last">...</li>

Read More At :