Introduction
The ‘<code>
‘ element in HTML is used to define a piece of code within the text. The purpose of the <code>
element is to distinguish code from the surrounding text and to ensure that it is displayed in a monospaced or fixed-width font, which is a common convention for code.
Here is an example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>Hello World</p>
<code>Hello World</code>
</body>
</html>
Output :
The ‘<code>
‘ element is useful for marking up inline code snippets, making them visually distinct from the surrounding text, and indicating to browsers that the content should be displayed in a fixed-width font.