Represents source code contained in the text.


<code><!-- Code snippet lives here --></code>

<code> is a tag that wraps around a block of text. By default it appears inline with the surrounding text, and can be used with a <pre> tag to create formatted code blocks across multiple lines.


Suppose the document contains a description of what a JavaScript function aims to accomplish, as well as the code for that function:

<head> </head>
<!-- Here <code> is being used inline, and the text add() will be shown in a monospace font -->
The function <code>add()</code> is defined below. It will take two inputs,
and return the sum of them as an output.
<!-- Here <code> is being used with a <pre> tag to allow the formatted code to span multiple lines -->
<code>function add(x, y) {
return x + y;
Edit this page on GitHub


Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn HTML on Codecademy

Edit this page on GitHub