I want to use a custom style for code snippets in my blog. I defined the following style:
mystyle {
background: #C3FFA5;
border: solid 1px #19A347;
color: #191919;
display: block;
font-family: monospace;
font-size: 12px;
margin: 8px;
padding: 4px;
white-space: pre;
}
I use it as follows:
<mystyle>
int main() {
cout << "Hello World" << endl;
}
</mystyle>
This gives the following output. I have tried on Firefox and Google Chrome.
I want to remove the extra line at the start of the block. Obviously, I understand where the newline comes from, and that I can use <mystyle>int main() {
instead. If I use <pre>
instead of <mystyle>
, there is no extra newline, so is it possible to do this with my custom style too?