The HTML <code>
element is used to define a piece of computer code. The content inside is displayed in the browser’s default monospace font.
The HTML <code> element is used to define a piece of computer code. The content inside is displayed in the browser's default monospace font.
Notice that the <code>
element does not preserve extra whitespace and line-breaks.
To fix this, you can put the <code>
element inside a <pre>
element:
<!DOCTYPE html> <html> <body> <p>The code element does not preserve whitespace and line-breaks.</p> <p>To fix this, you can put the code element inside a pre element:</p> <pre> <code> x = 5; y = 6; z = x + y; </code> </pre> </body> </html>