- Element of
- Guide To Fonts And Web Typography No HTML Developer Can Do Without
- What does
<code> HTML Tagdo?
- The <code> element is used to define enclosed text as computer code. It is often paired with the <pre> element to preserve line breaks and indentation when presenting blocks of computer code.
The <code><code></code> element defines inline code.
<code>element defines inline code.
Not all you need
If you want to present code samples in your site, the
<code> element is not the only thing you'll need. For multi-line (“block”) code presentation, the most common approach is to use the
<pre> element, and then put the
<code> element inside that. Additionally, special characters that don't render properly in HTML (like angle-brackets and ampersands) may need to be converted into their appropriate HTML Character Entity codes. This is highly error-prone work if done by hand. If you are writing a lot of code samples for your site, you may want to look at automated code rendering via a system like Markdown or an embedding service like Github's gist.
Browser Support for code