The HTML <code>
element displays its contents styled in a fashion
intended to indicate that the text is a short fragment of computer
code. By default, the content text is displayed using the
user agent's default monospace font.
Attributes
This element only supports the global attributes.
Usage notes
To represent multiple lines of code, wrap the <code>
element within a
<pre>
element. The <code>
element by itself only represents a single phrase
of code or line of code.
A CSS rule can be defined for the code
selector to override the
browser's default font face. Preferences set by the user might take
precedence over the specified CSS.
Examples
HTML
<p>The function <code>selectAll()</code> highlights all the text in the
input field so the user can, for example, copy or delete the text.</p>
Result
Desktop | Mobile | |||
---|---|---|---|---|
Chrome | Edge | Chrome | Edge | |
video | 3 | Yes | ? | No |
See also
mfuji09, wbamberg, SphinxKnight, roryokane, Wilfred, yuheiy, crissdev, Sheppy, teoli, Sebastianz, CarloMartini, sideshowbarker, rudijuri, erikadoyle, MadeByMike, Volker-E, Jeremie, kscarfone, justleroy, tregagnon, medicdude, ethertank, lmorchard, grendel, cers, McGurk, hobophobe, xaky, jswisher, Ptak82, Qk9Ka7, Jscher2000, PablO, alecananian