Our volunteers haven't translated this article into عربي yet. Join us and help get the job done!
The HTML Code Element (<code>) represents a fragment of computer code. By default, it is displayed in the browser's default monospace font.
Content categories | Flow content, phrasing content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parent elements | Any element that accepts phrasing content. |
DOM interface | HTMLElement Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the HTMLSpanElement interface for this element. |
Attributes
This element only includes the global attributes.
Example
<p>Regular text. <code>This is code.</code> Regular text.</p>
Result
Regular text. This is code.
Regular text.
Note
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.
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of '<code>' in that specification. |
Living Standard | |
HTML5 The definition of '<code>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<code>' in that specification. |
Recommendation |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
MadeByMike,
Sebastianz,
Volker-E,
Jeremie,
kscarfone,
justleroy,
tregagnon,
Sheppy,
medicdude,
ethertank,
teoli,
lmorchard,
grendel,
cers,
McGurk,
hobophobe,
xaky,
jswisher,
Ptak82,
Qk9Ka7,
Jscher2000,
PablO,
Rappo
Last updated by:
MadeByMike,