Use the pre tag when displaying inline code snippets
The pre tag preserves formmatting and does not eliminate white space (unlike the other tags which do eliminate whitespace). This is important when displaying inline code snippets so that code indenting is preserved.
Another little note is that when using the div tag, CSS margins and padding is not preserved. I probably just don't understand HTML. Anyway, here are some examples:
Using div:
Using pre:
Notice that when I use pre my indentation and margines are preserved, while they are discarded when using div.
Another little note is that when using the div tag, CSS margins and padding is not preserved. I probably just don't understand HTML. Anyway, here are some examples:
Using div:
void foo ()
{
int a = -1
return a;
}
{
int a = -1
return a;
}
Using pre:
void foo ()
{
int a = -1
return a;
}
Notice that when I use pre my indentation and margines are preserved, while they are discarded when using div.
3 Comments:
I'm just commenting becasue I love your name. I've been waiting my whole life to meet someone named Hans. Cool blog.
I'm just commenting becasue I love your name. I've been waiting my whole life to meet someone named Hans. Cool blog.
I'm sorry that I left two copies of my previous comment...I don't know how it ended up that way.
Post a Comment
<< Home