Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<code>

A piece of code inside text; shown in a monospace font.

Syntax

<code>console.log()</code>

Examples

A function name and a tag name inside a paragraph:

<p>Call <code>alert()</code> to show a message.</p>
<p>Wrap paragraphs in the <code>&lt;p&gt;</code> tag.</p>

Styling with CSS:

<style>
  code { background: #eee; padding: 2px 4px; border-radius: 4px; }
</style>
 
<p>Use <code>git status</code> to see changes.</p>

Notes

Replace < and > inside code with &lt; and &gt;, otherwise the browser treats them as tags. Multi-line code is wrapped in <pre><code>…</code></pre>.

See also

  • <pre> — Text that keeps all spaces and line breaks.
  • <kbd>, <samp>, <var> — Keyboard input (`<kbd>`), program output (`<samp>`) and a variable in a formula (`<var>`).

In the tutorial

  • Text formatting — Inline tags for text — strong and em, mark, del and ins, sub and sup, code, kbd and pre, abbr and q.

Thanks for reading!

Donate to the site — we work hard for you.