Search code examples
htmlxhtmlepub

xhtml doesn't see <pre><code> as text


I have a problem, I want to write an epub book. I see it uses xhtml. I want to make something like the stackoverflow code block. Here is my CSS code:

pre{
font-size: 1em;
line-height: 1.5em;
background: #EEE;
padding: .75em;
margin: 1.5em 0 1.5em 0;
font-family: "Courier New",Courier,monospace;
font-family: Verdana, Geneva, sans-serif;
color: #666;
}

And my HTML code:

<pre><code></code></pre>

I tried using it with "quotation marks" and with 'apostrophes', but Sigil, which I am currently using sees it as an HTML code and gives me errors.

Please help me.


Solution

  • You should escape the < inside the "code block" as &lt;. Or you might be able to enclode the code block in a <![CDATA[ ... ]]> block.