Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<code>

摘要

HTML <code> 元素呈现一段计算机代码. 默认情况下, 它以浏览器的默认等宽字体显示.

属性

此元素仅包含 全局属性.

例子

<p>Regular text. <code>This is code.</code> Regular text.</p>

结果

Regular text. This is code. Regular text.

(中文的等宽字和正常字看起来区别不大, 因为汉字本身就是方块行. 但是仍能看出几行文字之间的对齐差异)

注意

CSS 规则可以覆盖浏览器默认的 code 标签字体样式. 但用户设置的浏览器字体选项可能会超过 CSS 的优先级, 使之无效.

Specifications

Specification Status Comment
WHATWG HTML Living Standard Living Standard  
HTML5 Candidate Recommendation  
HTML 4.01 Specification Recommendation  

浏览器兼容性

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

文档标签和贡献者

 此页面的贡献者: ziyunfei, guoyunhebrave
 最后编辑者: ziyunfei,