msmith1114
msmith1114

Reputation: 3229

Proper way to display "Code" sections in HTML/CSS?

Is there a "best way". Something that sort of makes the portion of code look inset?

For instance, how SO displays "code" sections on posts for example?

I know Bootstrap has "Wells" but when not using it, is there a particular way that is functional looks nice?

Upvotes: 1

Views: 79

Answers (1)

dippas
dippas

Reputation: 60553

You can use the tag pre or code for that kind of things.

code { 
    background: rgba(0,0,0,.2)
}

pre {
    white-space: pre-wrap;
    background: rgba(0,0,0,.2)
}
The <code>&lt;code&gt;</code> tag.

<pre>
Here's a  &lt;pre&gt; tag. some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text some more text 
</pre>

Upvotes: 2

Related Questions