Lessons
HTML
- HTML HOME
- HTML Introduction
- HTML Editors
- HTML Basic
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Styles
- HTML Formatting
- HTML Quotations
- HTML Comments
- HTML Colors
- HTML CSS
- HTML Links
- HTML Images
- HTML Tables
- HTML Lists
- HTML Blocks
- HTML Classes
- HTML Id
- HTML Iframes
- HTML JavaScript
- HTML File Paths
- HTML Head
- HTML Layout
- HTML Responsive
- HTML Computercode
- HTML Entities
- HTML Symbols
- HTML Charset
- HTML URL Encode
- HTML XHTML
HTML5
HTML Graphics
HTML Media
HTML APIs
HTML Examples
HTML References
- HTML Tag List
- HTML Attributes
- HTML Events
- HTML Colors
- HTML Canvas
- HTML Audio/Video
- HTML Doctypes
- HTML Character Sets
- HTML URL Encode
- HTML Lang Codes
- HTML Messages
- HTML Methods
- PX to Em Converter
- Keyboard Shortcuts
HTML Forms
HTML Computercode
HTML Computer Code Elements
Computer Code
<code>
x = 5;<br>
y = 6;<br>
z = x + y;
</code>HTML <kbd> For Keyboard Input
The HTML <kbd> element represents user input, like keyboard input or voice commands.
Text surrounded by <kbd> tags is typically displayed in the browser's default monospace font:
Example
<p>Save the document by pressing <kbd>Ctrl + S</kbd></p>Result:
HTML <samp> For Program Output
The HTML <samp> element represents output from a program or computing system.
Text surrounded by <samp> tags is typically displayed in the browser's default monospace font:
Example
<p>If you input wrong value, the program will return <samp>Error!</samp></p>Result:
HTML <code> For Computer Code
The HTML <code> element defines a fragment of computer code.
Text surrounded by <code> tags is typically displayed in the browser's default monospace font:
Example
<code>
x = 5;
y = 6;
z = x + y;
</code>Result:
x = 5; y = 6; z = x + y;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:
Example
<pre>
<code>
x = 5;
y = 6;
z = x + y;
</code>
</pre>Result:
x = 5; y = 6; z = x + y;
HTML <var> For Variables
The HTML <var> element defines a variable.
The variable could be a variable in a mathematical expression or a variable in programming context:
Example
Einstein wrote: <var>E</var> = <var>mc</var><sup>2</sup>.Result:
HTML Computer Code Elements
| Tag | Description |
|---|---|
| <code> | Defines programming code |
| <kbd> | Defines keyboard input |
| <samp> | Defines computer output |
| <var> | Defines a variable |
| <pre> | Defines preformatted text |