Last Updated : 21 Nov, 2024
The HTML <code> tag is a semantic element used to define a piece of computer code. When creating web pages, it's often necessary to display programming code, and the <code> tag makes it easy to do so.
The <code> tag is specifically designed to display computer output, such as code snippets, in a web browser. It's an essential element for developers, coders, and educators who need to share code online.
HTML
<!DOCTYPE html>
<html>
<body>
<code>
console.log("Welcome to GeeksforGeeks")
</code>
</body>
</html>
Syntax
<code> Contents... </code>Key Features
<code> tag can also nest the within other HTML tags. For example, use it in a <pre> tag, which preserves whitespace and formatting:
HTML
<!DOCTYPE html>
<html>
<head>
<title>Code Tag Example</title>
</head>
<body>
<h3>Code Example</h3>
<pre>
<code>
function greet(name) {
return "Hello, " + name + "!";
}
</code>
</pre>
</body>
</html>
Note: The browser support list may not be exhaustive, but the <code> tag is widely supported and used in web development.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4