HTML element computer code
Computer code var person = {firstName: "Bill", lastName: "Gates", age: 50, eyeColor: "blue"}
Computer code typically HTML format, HTML letters using a variable size, and a variable letter spacing.
When displaying computer code sample does not require so.
<Kbd>, <samp>, and <code> all support element fixed letter size and spacing.
Keyboard HTML format HTML <kbd> element defines the keyboard:
实例<p>To open a file, select:</p><p><kbd>File | Open...</kbd></p>
Try it yourself
Sample HTML format HTML <samp> element defines a computer output:
实例<samp>demo.example.com login: Apr 12 09:10:17Linux 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189</samp>
Try it yourself
HTML code format HTML <code> element defines the programming code examples:
实例<code>var person = { firstName:"Bill", lastName:"Gates", age:50, eyeColor:"blue" }</code>
Try it yourself
<Code> element does not retain extra spaces and wrap:
实例<p>Coding Example:</p><code>var person = { firstName:"Bill", lastName:"Gates", age:50, eyeColor:"blue"}</code>
Try it yourself
To solve this problem, you must surround the code in <pre> element:
实例<p>Coding Example:</p><code><pre>var person = { firstName:"Bill", lastName:"Gates", age:50, eyeColor:"blue"}</pre></code>
Try it yourself
Variable HTML formatting HTML <var> element defines the mathematical variables:
实例<p>Einstein wrote:</p><p><var>E = m c<sup>2</sup></var></p>