HTML code tag
Example
Define some text as computer code in a document:
<p>The CSS <code>background-color</code> property defines the background color of an element.</p>
The HTML button
tag defines a clickable button.
The CSS background-color
property defines the background color of an element.
Definition and Usage
The <code>
tag is used to define a piece of computer code. The content inside is displayed in the browser's default monospace font.
Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).
Also look at:
Tag | Description |
---|---|
<samp> | Defines sample output from a computer program |
<kbd> | Defines keyboard input |
<var> | Defines a variable |
<pre> | Defines preformatted text |
Global Attributes
The <code>
tag also supports the Global Attributes in HTML.
Event Attributes
The <code>
tag also supports the Event Attributes in HTML.
More Examples
Example
Use CSS to style the <code> element:
<head>
<style>
code {
font-family: Consolas,"courier new";
color: crimson;
background-color: #f1f1f1;
padding: 2px;
font-size: 105%;
}
</style>
</head>
<body>
<p>The HTML <code>button</code> tag defines a clickable button.</p>
<p>The CSS <code>background-color</code> property defines the background color of an element.</p>
</body>
</html>
The HTML button
tag defines a clickable button.
The CSS background-color
property defines the background color of an element.
Default CSS Settings
Most browsers will display the <code>
element with the following default values:
Example
font-family: monospace;
}
Comments
Post a Comment